Android 我有一个文本视图,它总是以固定大小显示
我正在修复聊天机器人的UI细节,而textview的大小固定不变,我不明白为什么会发生这种情况。它按预期工作,但在主要对值文件进行了一些更改之后,您可以在下面的链接中看到结果Android 我有一个文本视图,它总是以固定大小显示,android,xml,view,textview,width,Android,Xml,View,Textview,Width,我正在修复聊天机器人的UI细节,而textview的大小固定不变,我不明白为什么会发生这种情况。它按预期工作,但在主要对值文件进行了一些更改之后,您可以在下面的链接中看到结果 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="vertical"
android:padding="@dimen/size_8dp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginStart="6dp"
tools:text="User" />
<TextView
android:id="@+id/message_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="@dimen/chat_bubble_max_width"
android:layout_gravity="end"
android:layout_marginTop="6dp"
android:background="@drawable/user_bubble_bck"
android:hint="@string/user_text_hint"
android:paddingStart="@dimen/chat_bubble_horizontal_padding"
android:paddingTop="@dimen/chat_bubble_vertical_padding"
android:paddingEnd="@dimen/chat_bubble_horizontal_padding"
android:paddingBottom="@dimen/chat_bubble_vertical_padding"
android:textColor="@color/user_bubble_text"
android:textColorHint="@color/user_bubble_text"
android:fontFamily="@font/montserrat_regular"
android:textFontWeight="400"
android:textSize="@dimen/text_size" />
</LinearLayout>
删除
android:hint
否则,您的文本视图大小将是android:hint
值或android:text
值,以字符长度较大者为准 我想这是因为maxWidth参数。如果不需要,请删除该参数,并将布局宽度设置为与父项匹配。这些是尺寸260dp 10dp 4dp 4dp 2dpit不会改变任何内容。顺便说一句,这个参数是由设计师设置的。你能分享一下可绘图文件“user\u bubble\u bck”中的内容吗?我发现了这个问题,但我不知道为什么它会影响TextView的大小。固定大小是提示的大小。当我删除提示时,它会按预期工作。如果有人对为什么会发生这种情况有所了解,请随时发布答案