【问题标题】:React Native TextInput how to start overflown text from left?React Native TextInput如何从左侧开始溢出文本?
【发布时间】:2018-03-19 04:57:56
【问题描述】:

我需要对齐这个长文本,它应该从左边开始。如下图所示,文本的结尾很好地显示,开始被隐藏。 如何从左开始文本,

alignText: 'left' 

没用。

  Geocoder.geocodePosition({
    lat: origin.latitude,
    lng: origin.longitude
  }).then(res => {
    console.log(res[0]);
    this._destination.setAddressText(res[0].formattedAddress);
  });

这里formattedAddress很长,我要从头显示出来。

默认情况下,这适用于 iOS。

【问题讨论】:

  • 请用您的代码更新您的问题。
  • @VahidBoreiri 添加了代码
  • 你有解决办法吗????
  • @Benedict 我做到了,但不是以正确的方式,我所做的是从末尾截断整个文本,只保留可见的数量

标签: react-native textinput


【解决方案1】:

尝试最大长度。根据可见文本大小为 maxlength 赋值。否则,如果要显示全文,请使用 multiline=true。

例如:

<TextInput maxLength={50} />

了解更多信息:

https://reactnative.dev/docs/textinput.html#maxlength

https://reactnative.dev/docs/textinput.html#multiline

【讨论】:

    【解决方案2】:

    你需要了解 react native 中的弹性盒子系统:

    flexDirection : 'row' -> used to set the text in row direction.
    
    alignSelf : 'flex-start' -> used to set the start from the left.
    

    也请从那里阅读React Native Basics flexbox

    【讨论】:

    • 这是我的文字 View> 在 View 的帮助下,如果它不起作用,请尝试 justifyContent。
    • 请编辑您在代码中放置 css 的位置的问题。这样我就可以相应地设置它
    猜你喜欢
    • 2021-02-02
    • 2017-02-05
    • 1970-01-01
    • 2021-09-27
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-05
    相关资源
    最近更新 更多