【发布时间】:2019-09-28 07:41:12
【问题描述】:
我有一个平面列表呈现如下视图
<TouchableOpacity style= {styles.AdRow} onPress={() => this.Navigatioe(item.id)}>
<View style = {styles.LeftItems}>
<Image source={{uri:item.url}} style={styles.ImagePRosa} />
</View>
<View style = {styles.RightItems}>
<Text style = {styles.TitleText}>{item.title}</Text>
<Text style = {styles.TitlePrice}>{item.price}</Text>
<Image source={require('../Svg/Location.png')} style={styles.ImagePRosing} />
<Text style = {styles.TitleCity}>{item.city}</Text>
<Text style = {styles.TitleNeib}>{item.neib}</Text>
</View>
</TouchableOpacity>
样式是
LeftItems:{
width:"40%",
height:"100%",
},
RightItems:{
width:"60%",
position:"relative",
height:"100%",
},
TitleText:{
position:"absolute",
top:4,
width:"100%",
height:65,
left:0,
right:0,
},
TitlePrice:{
position:"absolute",
bottom:0,
width:"40%",
height:25,
left:5,
},
TitleCity:{
position:"absolute",
bottom:23,
width:130,
height:18,
right:40,
},
TitleNeib:{
position:"absolute",
bottom:2,
width:130,
height:18,
right:40,
},
这对于 rtl 和 ltr 都是需要的,但是因为文档说
没有“真正的”左/右
如前所述,我们将 JS 端的左/右样式映射到 开始/结束,所有留在 RTL 布局的代码在屏幕上变成“右边”, 代码中的右侧在屏幕上变为“左侧”。这很方便,因为 您不需要过多更改产品代码,但这意味着 无法在代码中指定“真左”或“真右”。在 未来,允许组件控制其方向,无论 可能需要语言。
所以在 rtl 和 ltr 期间是否可以保持相同的视图,因为其中的数据是多语言的
【问题讨论】:
-
您找到解决方案了吗?
-
你找到解决办法了吗?
-
不,我只是为 ltr 和 rtl 创建了两种样式,用于 ltr 右为左,左为右,并检查语言是否为 rtl,如果是,我选择了另一种样式,您也可以在 react 中禁用 rtl 支持如果需要,原生
标签: react-native