Quantcast
Channel: Active questions tagged touch-feedback+android-recyclerview+rippledrawable - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Unusual RecyclerView item touch feedback

$
0
0

After creating a RecyclerView, I noticed some weird behaviour when an item is clicked. The ripple effect is shown, but after that the whole item gets highlighted. Does anyone know why the RecyclerView item behaves in this way and whether or not this is some sort of bug?

enter image description here

RecyclerView item layout (single line)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearlayout_listitem_singleline"
    android:foreground="?android:attr/selectableItemBackground"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/listitem_singleline_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="12dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="?android:attr/textColorPrimary" />

</LinearLayout>

RecyclerView item layout (dual line)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/relativelayout_listitem_dualline"
    android:foreground="?android:attr/selectableItemBackground"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:baselineAligned="false"
    android:padding="12dp"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView android:id="@+id/listitem_dualline_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:ellipsize="marquee"
        android:textColor="?android:attr/textColorPrimary"
        android:fadingEdge="horizontal" />

    <TextView android:id="@+id/listitem_dualline_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignStart="@id/listitem_dualline_title"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:ellipsize="marquee"
        android:textColor="?android:attr/textColorSecondary"
        android:layout_below="@id/listitem_dualline_title"
        android:fadingEdge="horizontal" />
</RelativeLayout>

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images