TL;DR - 我正在使用一个水平的可回收视图,每个单元格宽度为wrap_content,在除三星设备外的所有设备上都能正常工作。
我的list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scope_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_scope_state_normal"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp">
<TextView
android:id="@+id/scope_text"
android:layout_centerInParent="true"
android:background="?attr/selectableItemBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="2/2017"/>
</RelativeLayout>
现在,这是在三星S3上使用此代码的效果: 如果我将list_item.xml中相对布局的宽度更改为80dp,则效果如下: 现在,您可以看到文本具有不同的宽度,并且使用固定宽度时,长单词中缺少字母,wrap_content应根据文本视图宽度设置宽度,但在三星手机上,这并不起作用,它只会拉伸布局... 我是否遗漏了什么?