异常
如果发现使用的MaterialAutoCompleteTextView组件弹出的下拉列表框中的文本项没有自动换行,而是超过限度则省略掉了。
错误代码
使用的自定义布局item_multiline_dropdown.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:singleLine="false"
android:maxLines="3"
android:ellipsize="end"
android:textSize="16sp"
android:textColor="#DE000000"
android:lineSpacingExtra="4dp"
android:text="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
android:minWidth="100dp"/>
解决
给TextView组件套上一个LinearLayout布局。
正确代码
最后修改后的正确代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:maxLines="3"
android:ellipsize="end"
android:textSize="16sp"
android:textColor="#DE000000"
android:lineSpacingExtra="4dp"
android:textAppearance="?attr/textAppearanceSubtitle1"/>
</LinearLayout>
2万+

被折叠的 条评论
为什么被折叠?



