Look at the renderings first
In fact, it is very simple to achieve this effect. Just divide the two folders of drawable and drawablev21 .
Normally, selector:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/menu_selected" android:state_pressed="true" /> <item android:drawable="@android:color/transparent" /></selector>
Selector in v21:
<?xml version="1.0" encoding="utf-8"?><ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/menu_selected" ><!-- Color of press--> <!-- drawable/color/bitmap for bottom background --> <!--<item android:drawable="@color/red" />--></ripple>
Here, color in ripple is the pressed water ripple color, add an item to it, and this item will become the background.
Note that do not add transparent item as background. One is meaningless, and the other is that the pressing effect cannot be displayed.
The above is the entire content of this article. I hope the content of this article will be helpful to everyone in developing Android.