如果您有一个TextView,其
有什么解决方法吗?
更新:回答者/评论者没有理解重点。也许我上传的图片会让人感到困惑,因为它是从我的应用程序中进行样式设置的。任何TextView都会出现问题,您可以通过设置背景来查看视图边界将不再紧密。我上传了另一张图片。以下是图像中TextView的XML:
layout_width="wrap_content"
,并且它必须换行才能容纳文本,则它将调整其宽度以使用所有可用空间(考虑边距等)。但是为什么视图末尾有填充?我只是告诉它wrap_content,所以它应该包裹内容!这似乎是一个错误,在股票Messenger应用程序的聊天UI中可见。(图片来自我的应用程序。但那个额外的空间绝对不在9 patch中。)有什么解决方法吗?
更新:回答者/评论者没有理解重点。也许我上传的图片会让人感到困惑,因为它是从我的应用程序中进行样式设置的。任何TextView都会出现问题,您可以通过设置背景来查看视图边界将不再紧密。我上传了另一张图片。以下是图像中TextView的XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:background="#dddddd"
android:text="This doesn't wrap"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_gravity="center_horizontal"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_gravity="center_horizontal"
android:background="#dddddd"
android:text="This wraps and look, the bounds does not fit tight against the right edge of text"
/>