如何在屏幕中央设置加载程序并锁定屏幕直到获得响应在反应原生

问题描述

我是本机反应的新手。我正在尝试显示加载程序,直到从服务器获得响应。当加载程序显示我想锁定屏幕时,意味着用户无法滚动或无法执行任何操作。 这是加载程序代码

import {ActivityIndicator} from 'react-native

 isLoading: true,<ScrollView style={{ flex: 1,height: Dimensions.get('window').height / 1.1,}}>

  <View style={{ flex: 1,justifyContent: "center",alignItems: "center" }}>
        {this.state.isLoading && <ActivityIndicator  size="large" color={"orange"} />}
      </View>

</ScrollView>

请帮忙谢谢。通过添加代码。我无法在中心显示该加载程序,当我向下滚动时,该加载程序上升并且无法显示

解决方法

import {ActivityIndicator} from 'react-native

 if(isLoading){
     <View style={{ flex: 1,justifyContent: "center",alignItems: "center" 
      }}>
        <ActivityIndicator  size="large" color={"orange"} />
     </View>
}
else {
    <ScrollView style={{ flex: 1,height: Dimensions.get('window').height / 1.1,}}>

   /* your rest code * /

  </ScrollView>
}