Use the numberOfLines
parameter on a Text
component:
<Text numberOfLines={1}>long long long long text<Text>
Will produce:
long long long…
(Assuming you have short width container.)
Use the ellipsizeMode
parameter to move the ellipsis to the head
or middle
. tail
is the default value.
<Text numberOfLines={1} ellipsizeMode='head'>long long long long text<Text>
Will produce:
…long long text
NOTE: The Text
component should also include style={{ flex: 1 }}
when the ellipsis needs to be applied relative to the size of its container. Useful for row layouts, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…