我有一个平面列表呈现如下视图
<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>
Run Code Online (Sandbox Code Playgroud)
和造型是
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,
},
Run Code Online (Sandbox Code Playgroud)
这对于 rtl 和 ltr 都是需要的,但是因为文档说
左/右没有“真”
如前所述,我们将 JS 端的 left/right 样式映射到 start/end,RTL 布局代码中的所有 left 都在屏幕上变为“right”,代码中的 right 在屏幕上变为“left”。这很方便,因为您不需要对产品代码进行太多更改,但这意味着无法在代码中指定“真左”或“真右”。将来,可能需要允许组件控制其方向而不管语言如何。
那么在 rtl 和 ltr 期间是否可以保持相同的视图,因为其中的数据是多语言的
Sub*_*bha -3
像这样导入:
import { I18nManager } from 'react-native'
Run Code Online (Sandbox Code Playgroud)
强制使用 RTL:
I18nManager.forceRTL(true);
Run Code Online (Sandbox Code Playgroud)
并在 textInput 上使用 textAlign : "right" 表示 RTL或textAlign : "left" 表示 LTR 。
如果您不想要 RTL,则使用:
I18nManager.allowRTL(false);
Run Code Online (Sandbox Code Playgroud)
这是RN 官方博客链接,您将在其中获得详细的用例。
| 归档时间: |
|
| 查看次数: |
645 次 |
| 最近记录: |