【发布时间】:2021-03-01 19:28:37
【问题描述】:
我注意到,在使用 React native 添加“视图”时,即使我没有输入任何样式,它的行为也好像分配了“宽度:'100%'”。任何组件都存在相同的情况。它水平覆盖整个区域。是什么原因和解决方法?
return (
<View style={{flex:1}}>
{/* paints the line he is in full red but should only paint as much as the line of the text */}
<View style={{backgroundColor:'red'}}>
<Text>Example</Text>
</View >
</View>
);
【问题讨论】:
-
请指定你想要的而不是
width: 100% -
我不想为每个元素输入宽度。我不认为你会回应。
-
没有。代码仅作为附件。
标签: react-native view styles