【问题标题】:Cant align text right in android with react native无法在android中使用react native正确对齐文本
【发布时间】:2021-02-23 07:17:52
【问题描述】:

由于某种原因,我无法使用 react native 在 android 中正确对齐文本。我的代码在 iOS 上运行良好,但在 android 上没有。有人知道原因或解决方法吗?

布局

<View style={styles.viewOC}>
         <Text style={styles.leftText}> Left</Text>
         <Text style={styles.rightText}> Right</Text>
  </View>

样式

...
  viewOC: {
    paddingTop: 8,
    flexDirection: "row",
    justifyContent: "space-between",
    width: "100%",
    textAlignVertical: "center",
    alignSelf:"stretch",
  },
  leftText: {
    textAlign: "left",
    fontSize: 12,
    justifyContent: "center",
    textAlignVertical: "center",
    justifyContent: "flex-start",
    alignSelf: "flex-start",
  },
  rightText: {
    textAlign: "right",
    fontSize: 12,
    maxWidth: "50%",
    textAlignVertical: "top",
    justifyContent: "flex-end",
    alignSelf: "flex-end",
  }...

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    尝试仅使用这些属性

    const styles = StyleSheet.create({
       
      viewOC: {
        paddingTop: 8,
        flexDirection: "row",
        justifyContent: "space-between",  
      },
      leftText: { 
        fontSize: 12,
      },
      rightText: { 
        fontSize: 12, 
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-22
      • 1970-01-01
      相关资源
      最近更新 更多