Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 水平回收视图包装内容不';在三星上做不好?_Android_Android Recyclerview - Fatal编程技术网

Android 水平回收视图包装内容不';在三星上做不好?

Android 水平回收视图包装内容不';在三星上做不好?,android,android-recyclerview,Android,Android Recyclerview,TL;DR-我使用的是一个水平回收器视图,每个单元上都有包裹内容宽度,除了三星设备外,它在所有设备上都能正常工作 my 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/tool

TL;DR-我使用的是一个水平回收器视图,每个单元上都有包裹内容宽度,除了三星设备外,它在所有设备上都能正常工作

my 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应该根据文本视图宽度设置宽度,但在samsungs上这不起作用,它只是拉伸布局。。我遗漏了什么吗?

你可以删除Eugen在评论中所说的包装
RelativeLayout
,并使用recyclerview的内部系统来绘制漂亮的背景。 这将修复您的UI


此外,还可以使用转储视图层次结构,并查看S3

小的不相关注释的实际值。为什么需要相对布局?如果你能用文本视图拥抱那个男人,我想这会解决你的问题