RN flex布局和absolute 布局实践

本文详细介绍了使用React Native进行UI布局和样式设置的方法,包括绝对定位、Flexbox布局及自定义样式的应用。通过具体代码示例展示了如何创建复杂的界面组件,并探讨了样式属性如justifyContent、alignItems和position在不同布局场景下的使用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码如下:

return (

<View style={{height:200,backgroundColor:'#11D38B',alignItems:'center'}}>

 

<View style={{height:86,marginTop:120,width:global.width,backgroundColor:'#FFFFFF'}}>

</View>

 

{/* 中间那一块是绝对布局 */}

 

<View style={[{flexDirection:"column",justifyContent:"center",position:'absolute',alignItems:'center',width:global.width-40,height:145,borderRadius:12,bottom:26,backgroundColor:"#FFFFFF"},global.common.shadow]}>

 

<View style={{flexDirection:'row',alignItems:'center'}}>

<Text style={{fontSize:17,color:"#333333"}}>HKHKKK</Text>

<Text style={{fontSize:12,color:"#333333"}}>KKKKJK</Text>

</View>

 

<View style={{marginTop:5,flexDirection:'row',alignItems:'center'}}>

<Text style={{fontSize:12,color:"#333333"}}>HKHKKKJ</Text>

<Text style={{marginLeft:5,marginRight:5,fontSize:17,color:"#333333"}}>5</Text>

<Text style={{fontSize:12,color:"#333333"}}>KHKKJKKH</Text>

</View>

 

<View style={{marginTop:15,flexDirection:'row',justifyContent:'center',alignItems:'center'}}>

<View style={{width:64,height:0.5,backgroundColor:'#D5D5D5'}}>

</View>

<View style={{justifyContent:"center",alignItems:'center',width:54,height:17,borderRadius:8.5,borderWidth:1,borderColor:'#D5D5D5'}}>

<Text style={{color:"#A6A6A6",fontSize:10}}>{global.t('IO:HHKHKHKH')}</Text>

</View>

<View style={{width:64,height:0.5,backgroundColor:'#D5D5D5'}}>

</View>

</View>

 

<Text style={{marginTop:9,fontSize:12,color:"#A6A6A6"}}>{'HKHKHKHKHKHKHKH1'}</Text>

</View>

 

<Image source={{uri:"AppIcon"}} style={{position:'absolute',marginTop:10,width:45,height:45,borderRadius:22.5}} />


 

</View>

)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值