Horizontal RecyclerView wrap_content not working well on samsung?

TL DR - I use horizontal scrolling of the recycler with wrap_content width in each cell, and it works as expected on everything except samsung devices.

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>

now, here is how it looks on samsung s3 using this code: bad behavior

and it looks like this if I change the width of the relative layout in list_item.xml to 80dp: 80dp

now, since you can see that the texts have different widths and fixed widths, I skip letters in long words, wrap_content should set the width according to the width of the text view, but on samsungs it doesn’t work, it just stretches the layout .. I what something missing?

+4
source share
1

RelativeLayout, Eugen, recyclerview ItemDecorator .

Android Monitor , S3

+1

Source: https://habr.com/ru/post/1676659/


All Articles