javascript - 如何在 native react 中在屏幕中间显示图标

标签 javascript css reactjs react-native

在这里,我在中心显示 "icon="check-decagram"type="MaterialCommunityIcons",但它刚好位于中心,距离顶部有 20 个填充。我必须在中间显示它手机屏幕。我试过了,可能是我做错了。请指正。

return(
       <ImageBackground source={BG} style={styles.imgBG}>
           <ScrollView>
             <View>
                <Header title={title} icon={icon} navigation={navigation} />
             </View>
             <View style={{ flexDirection: 'column', backgroundColor: '#ffff',}}>
             <View style={{
                       flexDirection:'column', backgroundColor:'#fff',alignItems:'center',paddingTop:20,justifyContent: 'center'}}>
                <IconXL icon="check-decagram" type="MaterialCommunityIcons" style={{ color: 'green' }}/>

             </View>
             <View style={{
                       flexDirection:'row', backgroundColor:'#ffff',padding:20,flexWrap:'wrap'}}>
                <SmallText textColor="grey" text={`v${updateResponse.updateStatusList.currentAppVersion} `}/>
                <SmallText textColor="grey" text={`${updateResponse.updateStatusList.desc}`}/>
             </View>
             </View>

          </ScrollView>

      </ImageBackground>

 )}

//谢谢

最佳答案

尝试在图标的父 View 中添加两个属性 height: '100%'width: '100%',

喜欢,

<View style={{flexDirection:'column',height: '100%',width: '100%',backgroundColor:'#fff',alignItems:'center',paddingTop:2,justifyContent: 'center'}}>
  <IconXL icon="check-decagram" type="MaterialCommunityIcons" style={{ color:'green' }}/>
</View>

希望这对你有用,

祝你好运。

关于javascript - 如何在 native react 中在屏幕中间显示图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57145531/

相关文章:

javascript - HTML: 多个 onclick 音频文件,让最后一个停止

javascript - 如何处理 "outside"单击 Dialog (Modal)?

css - IE7 中的菜单悬停 z-index 错误

html - 如果我将 <span> 放在新行上,星星会改变位置

html - IE 7/8 渲染 Iinline (Floated Divs) 为 block : widths do not adjust to content?

node.js - 部署在 Netlify 上时使用 Express 公开 API 路由

javascript - react 导航 : Component is not being unmounted on pop or back button #5775

javascript - 验证 Google 电子表格并将其用作网络应用程序的数据库

javascript - 为什么 form.reset() 在重置处理程序中不起作用?

javascript - jQuery 事件在关闭后保留在文档中