gpt4 book ai didi

react-native - react native 有没有办法在特定 View 中禁用 rtl 或保持相同的外观

转载 作者:行者123 更新时间:2023-12-03 15:18:04 25 4
gpt4 key购买 nike

我有一个平面列表呈现如下 View

    <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 都是需要的,但是因为文档说

There is no "true" left/right

As discussed before, we map the left/right styles from the JS side to start/end, all left in code for RTL layout becomes "right" on screen, and right in code becomes "left" on screen. This is convenient because you don't need to change your product code too much, but it means there is no way to specify "true left" or "true right" in the code. In the future, allowing a component to control its direction regardless of the language may be necessary.



那么在 rtl 和 ltr 期间是否可以保持相同的 View ,因为其中的数据是多语言的

最佳答案

像这样导入:

import { I18nManager } from 'react-native'
要强制 RTL 使用:
I18nManager.forceRTL(true);
并使用 textAlign : "right"for RTL textAlign : textInput 上 LTR 的“左”。
如果您不想要 RTL,请使用:
I18nManager.allowRTL(false);
这是 RN Official Blog Link您将在其中获得详细的用例。

关于react-native - react native 有没有办法在特定 View 中禁用 rtl 或保持相同的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58144342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com