androidandroid-recyclerviewcardview

Border in RecyclerView Android


I'm using RecyclerView, there shouldn't be a border after each item in the recycle view, but I have. How to remove it? I think the problem is in the LayoutManager because there is not border in the last element of RecyclerView

<androidx.recyclerview.widget.RecyclerView
                android:background="@color/menu_background" //here is non border
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                tools:listitem="@layout/cabin_category_info_layout" />

And it's CardView

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp">

Solution

  • If you use CardView you should know that there's a default corner on this View so if you don't want it you should configure it to don't show it.

    Try adding this into your CardView

    app:cardCornerRadius="0dp
    

    Also if you want to remove the elevation you may use this too

    app:cardElevation="0dp"