Android Ripple effect for ImageView "state_select" Not Working

654 views Asked by At

I am developing Ripple effect for ImageView in Lolipop. My drawable XML is like below.

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="?android:colorControlHighlight"
    tools:targetApi="21">
    <item android:state_selected="true" android:drawable="@drawable/image_selected"/>
    <item android:state_pressed="true" android:drawable="@drawable/image_selected"/>
    <item android:drawable="@drawable/image_unselected"/>
</ripple>

And In XML i am giving SRC to ImageView like below.

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/iv_image"
        android:scaleType="fitXY"
        android:src="@drawable/bg_tab_item" />

My problem is in Activity.java, if i mention

ImageView.setSelected(true);

It is not showing selected image.

Please help me where i am doing wrong.

0

There are 0 answers