Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 中心活动指示器,绝对位置在React Native_Css_React Native_Activity Indicator - Fatal编程技术网

Css 中心活动指示器,绝对位置在React Native

Css 中心活动指示器,绝对位置在React Native,css,react-native,activity-indicator,Css,React Native,Activity Indicator,我正在使用视图覆盖和ActivityIndicator在后台隐藏加载地图。我使用的解决方案是绝对位置视图,使其位于所有内容之上,并将activityindicator置于顶部,因此发生了一些事情。 问题是,由于ActivityIndicator的大小不能设置为iOS上的特定像素,我不知道它的大小,因此我无法正确地将其居中。或者我没有想出办法 下面是一些代码: <View style={styles.whiteOverlay}> <ActivityIndicator

我正在使用视图覆盖和ActivityIndicator在后台隐藏加载地图。我使用的解决方案是绝对位置视图,使其位于所有内容之上,并将activityindicator置于顶部,因此发生了一些事情。 问题是,由于ActivityIndicator的大小不能设置为iOS上的特定像素,我不知道它的大小,因此我无法正确地将其居中。或者我没有想出办法

下面是一些代码:

<View style={styles.whiteOverlay}>
      <ActivityIndicator style={styles.indicator} size="large" color={colors.color4} />
 </View>

 whiteOverlay: {
        width: screen.height,
        height: screen.height,  
        backgroundColor: 'white',
        position: 'absolute',     
        zIndex: 20        
    },
    indicator: {
        zIndex: 21,
        position: 'absolute',
        left: screen.width/2,
        top: screen.height/2        
    }

白色覆盖:{
宽度:屏幕高度,
高度:screen.height,
背景颜色:“白色”,
位置:'绝对',
zIndex:20
},
指标:{
zIndex:21,
位置:'绝对',
左:screen.width/2,
顶部:屏幕高度/2
}

这将使指示器偏离中心。我可以把一些神奇的数字放在那里,让它在特定的设备上工作,猜测指示器的大小,但是在其他设备上就不起作用了。谢谢您的帮助。

如果您想将ActivityIndicator居中显示在屏幕上,可以这样设置样式


或者您可以使用样式的
位置


...
白色覆盖:{
位置:'绝对',
左:0,,
右:0,,
排名:0,
底部:0,
对齐项目:“居中”,
为内容辩护:“中心”
}

如果要将ActivityIndicator居中显示在屏幕上,可以这样设置样式


或者您可以使用样式的
位置


...
白色覆盖:{
位置:'绝对',
左:0,,
右:0,,
排名:0,
底部:0,
对齐项目:“居中”,
为内容辩护:“中心”
}
耦合选项

非弹性

whiteOverlay: {
   width: screen.height,
   height: screen.height,  
   backgroundColor: 'white',
   position: 'absolute',
   zIndex: 20        
},
indicator: {
   zIndex: 21,
   position: 'absolute',
   left: 50%,
   top: 50%,
   transform: translate(-50%, -50%)
}
使用Flex(假设指示器呈现为覆盖的子级)

夫妇选择

非弹性

whiteOverlay: {
   width: screen.height,
   height: screen.height,  
   backgroundColor: 'white',
   position: 'absolute',
   zIndex: 20        
},
indicator: {
   zIndex: 21,
   position: 'absolute',
   left: 50%,
   top: 50%,
   transform: translate(-50%, -50%)
}
使用Flex(假设指示器呈现为覆盖的子级)