I'm trying to implement a RecyclerView
with different list items. I don't know why but there is a shadow dropped by list items. This shadow appears when I scroll up and down. I want to get rid of this shadow, but found nothing that could help me. Any suggestions? Here's my XML:
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.admin.lanet_contactwork.activities.LoginActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
--------------------------------------Update: added item layouts----------------------------
FIRST ITEM LAYOUT
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/divider_txt"
android:layout_width="match_parent"
android:layout_height="48dp"
android:padding="8dp"
android:maxLines="1"
android:textSize="18sp"
android:background="@color/lightgrey"
android:textColor="@android:color/black"
android:textStyle="bold">
</TextView>
</LinearLayout>
SECOND ITEM LAYOUT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/task"
android:layout_width="match_parent"
android:layout_height="62dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/task_type_img"
android:layout_marginRight="5dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@mipmap/ic_sort_grey" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/address_txt"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="72dp"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_marginTop="12dp"
android:layout_toLeftOf="@+id/task_type_img" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10:00"
android:id="@+id/time_txt"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/address_details_txt"
android:layout_marginLeft="72dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="12dp"
android:textColor="@android:color/black"
android:textSize="14sp"
android:layout_toLeftOf="@+id/task_type_img" />
</RelativeLayout>
Add this to your RecyclerView
:
android:overScrollMode="never"
It works for me
`<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layout_marginTop="20dp"
android:paddingTop="0dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="0dp"/>`
android:overScrollMode="never"
This helped me to remove shadow at the start of the recyclerView and at the end as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With