gpt4 book ai didi

android - 在 TextView 中换行多行文本 - Android

转载 作者:太空宇宙 更新时间:2023-11-03 11:25:40 27 4
gpt4 key购买 nike

我有一个带有 layout_width="wrap_content"属性的多行 TextView。问题是什么时候TextView 实际上变成了多行,那么这个属性就不起作用了。我该如何解决此问题?

这是插图:

enter image description here

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"
/>

最佳答案

您似乎正在使用父 View (ViewGroup),您已经在其中为框定义了背景。您只需要为您的 TextView 而不是 ViewGroup 定义背景。所以,不要在你的 ViewGroup 中使用 background,尽量在 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>

关于android - 在 TextView 中换行多行文本 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11065854/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com