【发布时间】:2016-07-13 08:11:07
【问题描述】:
在 TextView 中,当单词的长度大于宽度可以容纳时,它会将文本换行并将其移动到下一行。但是,即使右侧有空白区域,TextView 也不会换行它自己的宽度。
如何让 TextView 在包裹文本时减小其宽度?
这是 TextView :
<TextView
android:id="@+id/userMessageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="40dp"
android:layout_marginTop="2dp"
android:autoLink="web"
android:background="@drawable/textview_design"
android:padding="8dp"
android:text="some text"
android:textColor="#333333"
android:textSize="17sp" />
还有,textview_design.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EEEEEE" />
<corners
android:radius="@dimen/chat_message_text_corner_radius" />
</shape>
【问题讨论】:
-
你在使用
android:layout_width="wrap_content"吗? -
在你的 xml 中为
textView制作你的android:layout_width=wrap_content -
显示这个文本视图的 xml 文件
-
@user13 是的,textview的布局宽度是wrap_content。
-
@Vickyexpert 我已经添加了 textview xml
标签: android textview word-wrap