我已经尝试过backgroundColor但没有成功。
我有以下代码,并希望将背景颜色应用于主父视图,但不想指定任何填充,如何实现此目的?
<View style={{flex:1,alignItems:'center'}}>
<Text>
No new Transactions
</Text>
<View style={{backgroundColor:'#fc004f',paddingTop:44,paddingBottom:40,top:56,borderRadius:8,width:window.width-20,borderWidth:2,borderColor:'#dddddd'}}>
<Text style={{position:'absolute',fontSize:16,top:14,paddingLeft:16,color:'white',fontWeight:'bold'}}>Big Bazaar</Text>
<Text style={{position:'absolute',fontSize:14,top:48,paddingLeft:16,color:'white',fontWeight:'bold'}}>View Receipt</Text>
</View>
<View style={{flex:1,backgroundColor:'#401f80',padding:44,top:56,borderRadius:8,width:window.width-20,borderWidth:2,borderColor:'#dddddd',marginTop:10}}>
<Text style={{position:'absolute',fontSize:16,top:14,paddingLeft:16,color:'white',fontWeight:'bold'}}>Zomato Inc</Text>
<Text style={{position:'absolute',fontSize:14,top:48,paddingLeft:16,color:'white',fontWeight:'bold'}}>View Receipt</Text>
</View>
<View style={{flex:1,backgroundColor:'#fc004f',padding:44,top:56,borderRadius:8,width:window.width-20,borderWidth:2,borderColor:'#dddddd',marginTop:10}}>
<Text style={{position:'absolute',fontSize:16,top:14,paddingLeft:16,color:'white',fontWeight:'bold'}}>OLA Inc</Text>
<Text style={{position:'absolute',fontSize:14,top:48,paddingLeft:16,color:'white',fontWeight:'bold'}}>View Receipt</Text>
</View>
</View>
最佳答案
从子视图中删除flex:1,然后将backgroundColor
添加到父视图中。希望这可以帮助!
关于javascript - 如何在不添加任何填充的情况下将背景颜色应用于View?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46674693/