TextView没有换行到多行

时间:2016-04-25 13:28:42

标签: android textview

我在 -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ [textField1 resignFirstResponder]; [textField2 resignFirstResponder]; } 中有一个TextView,它只显示其部分文字而不包装到换行符,并且无法理解原因。它甚至没有在某处显示省略号。

LinearLayout

TextView

我还尝试了 <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/import_progress_text" android:singleLine="false" android:maxLines="4" android:ellipsize="end" style="@style/TxtDefault" /> layout_weight=0,但仍然没有运气。 layout_height=0内的所有兄弟姐妹都设置了LinearLayout

修改

显然,当设置固定宽度时,它既可以使用,也可以使用layout_height=wrap_contentfill_parent。这是预期的行为吗?

按要求提供整个布局
请注意,FrameLayout内部是另一个不可见的,它是相当长的

match_parent

2 个答案:

答案 0 :(得分:0)

代码片段完美地包装到多行。 IDE可能存在一些问题,无法正确预览。在真实设备上进行测试。

答案 1 :(得分:0)

如果您想始终在n行中显示文字,只需添加android:lines="n", 或者如果它不起作用,请尝试使用TextView - &gt; android:textAppearance="?android:attr/textAppearanceLarge"

希望这会有所帮助。