React Native TextInput如何从左边开始溢出文本?

时间:2018-03-19 04:57:56

标签: react-native textinput

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

alignText: 'left' 

没有用。

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

这里的formattedAddress非常长,我需要从头开始显示它。

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

The overflown text

2 个答案:

答案 0 :(得分:3)

尝试maxLength。根据可见的文字大小为maxlength分配值。否则,如果要显示全文,请使用multiline = true。

例如:

<TextInput maxLength={50} />

详细了解它:

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

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

答案 1 :(得分:1)

您需要了解反应原生的弹性盒系统:

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