Listview does not respond with background effects when clicking on item

Asked

Viewed 54 times

0

listview code

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="#000000"
    android:dividerHeight="2dp"
    android:id="@+id/list_notify"
    >
</ListView>
</FrameLayout

code of the items that are contained in Listview

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  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="match_parent"
android:background="@drawable/list_item_selector">

<ImageView
    android:id="@+id/imageView_lista_notify"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_margin="4dp"
    android:src="@drawable/ic_menu_gallery" />

<TextView
    android:id="@+id/texto_hora_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:text="TextView"
    app:layout_constraintLeft_toRightOf="@+id/imageView_lista_notify"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="4dp" />

<TextView
    android:id="@+id/texto_notificacao_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:text="TextView"
    app:layout_constraintLeft_toRightOf="@+id/imageView_lista_notify"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toBottomOf="@+id/texto_hora_list" />



<ImageButton
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@android:drawable/ic_delete"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    android:id="@+id/imageButton"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="10dp" />
 </android.support.constraint.ConstraintLayout>

1 answer

0

Try to exchange the value of the "android:background" attribute of your Constraintlayout for this:

android:background="?attr/selectableItemBackground"

In Recyclerviews enables the click effect, I believe it should work for Listview as well.

Browser other questions tagged

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