我有一个带有layout_width =“wrap_content”属性的多行TextView。问题是当 TextView 实际上变成多行时,这个属性就不起作用了。我该如何解决这个问题?
这是插图:

XML:
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:focusable="false"
android:textSize="16.5dip"
android:padding="2dip"
android:lineSpacingMultiplier="1.1"
/>
Run Code Online (Sandbox Code Playgroud)
Dmi*_*huk -1
您似乎正在使用父视图(ViewGroup),其中您已经为框定义了背景。您只需要为 TextView 而不是 ViewGroup 定义背景即可。因此,不要在 ViewGroup 中使用背景,尝试在 textview 中使用它。例如:
<FrameLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:focusable="false"
android:textSize="16.5dip"
android:padding="2dip"
android:lineSpacingMultiplier="1.1"
android:background="@drawable/background_box"
/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1200 次 |
| 最近记录: |