Look at the effect chart first.
In fact, to achieve this effect is very simple, as long as drawable
drawablev21
two folders is good.
Selector in ordinary circumstances:
<?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>
The 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
><!--Press color-->
<!--bottom background drawable/color /bitmap-->
<!--<item android:drawable= "@color/red"/>-->
</ripple>
Here ripple
is the color
pressed water ripple color, add one inside item
, this item
will become the background.
note that do not add transparent to item
do the background, one is meaningless, the second will be unable to show the pressure effect of the problem.
This is the full content of this article, I hope the content of this article for everyone to develop Android can help.