Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set state_selected in ripple drawable

How to specify android:state_selected inside a RippleDrawable

I have following xml for ripple drawable but background color doesn't show up when I set myView.setSelected(true);

<?xml version="1.0" encoding="utf-8"?> <ripple     xmlns:android="http://schemas.android.com/apk/res/android"     android:color="#DDDDDD"     >      <item android:id="@android:id/mask">         <shape>             <solid                 android:color="@color/black" />         </shape>     </item>       <item android:state_selected="true">         <shape>             <solid                 android:color="#EEEEEE" />         </shape>     </item>       <item>         <color android:color="#FFFFFF" />     </item>  </ripple> 
like image 380
Sohaib Avatar asked Dec 16 '14 03:12

Sohaib


1 Answers

Found the answer, just in case someone else having the same problem

<?xml version="1.0" encoding="utf-8"?> <ripple     xmlns:android="http://schemas.android.com/apk/res/android"     android:color="#DDDDDD"     >       <item>         <selector>             <item android:state_selected="true">                 <color android:color="#EEEEEE" />             </item>              <item android:state_activated="true">                 <color android:color="#EEEEEE" />             </item>              <item>                 <color android:color="#FFFFFF" />             </item>         </selector>     </item>   </ripple> 
like image 107
Sohaib Avatar answered Sep 29 '22 11:09

Sohaib