我有以下 TextView
,layout_width
设置为 "wrap_content"
,就像这样
<TextView
android:id="@+id/my_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@+id/another_text_view"
android:layout_toRightOf="@+id/another_text_view"
android:background="@drawable/nice_background"
android:paddingLeft="15dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:layout_marginBottom="8dp"
android:duplicateParentState="true"
android:visibility="invisible" />
这就是发生的事情:
最佳答案
我认为这正是 TextView
的工作原理。除非您指定固定的 width
或 maxWidth
,否则文本的“环绕”假定文本现在将填充可用的水平空间。您唯一的选择是编写您自己的 TextView
版本(或覆盖 onMeasure
方法)...但这可能会变得困惑和复杂。
关于android - 背景不会在多行 TextView 上换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26911046/