Configure Cardview in Recyclerview

Asked

Viewed 139 times

0

I have a RecyclerView and use with CardView, the problem is that in one version of android the visualization is different from the other. I would like the visualization of android 9.0 to be the same as the 4.3.

Android 4.3 preview:

inserir a descrição da imagem aqui

Android 9.0 visulaização:

inserir a descrição da imagem aqui

XML of CardView:

<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="4dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="4dp">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="10dp"
            android:layout_height="10dp"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:layout_marginStart="16dp"
            android:background="@drawable/botao_menu_normal"
            android:padding="2dp" />

        <TextView
            android:id="@+id/txtLinhaCidade"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginStart="8dp"
            android:layout_marginTop="0dp"
            android:layout_toEndOf="@+id/imageView"
            android:text="Cidade"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold" />

    </RelativeLayout>


</android.support.v7.widget.CardView>

XML of RecyclerView:

<android.support.v7.widget.RecyclerView
        android:id="@+id/idRecycler"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="2dp"
        android:scrollbars="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textoCidade">

    </android.support.v7.widget.RecyclerView>
  • Try removing layout_margin from Relativelayout and placing a layout_padding in Cardview

  • It worked not, it gave the same result.

1 answer

2


I could find it, just put cardUseCompatPadding in Cardview with true.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.