<?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>
or add this to make a shape
<item>
<shape android:shape="rectangle">
<corners android:radius="50dp"/>
<solid android:color="#4444ff"/>
</shape>
</item>
ImageButton can not hold text inside. Button gets a shadow and ImageButton does not.
Add text view and image button inside a frame layout to display text inside the image button. This will not make a shadow effect.
Does not apply ripple effect if used selector drawable.
Buttons
Most buttons are made with several drawables. Usually you’ll have a pressed and normal version of assets like this:
/drawable/button.xml:<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/button_pressed"/>
<item android:drawable="@drawable/button_normal"/>
</selector>
If you have a custom button with selected state, your text color changes depending on the state, etc. So default button background is not going to work for you here. You can add this feedback for your own drawables and for custom buttons by simply wrapping them in a
ripple element:/drawable-v21/button.xml:<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:drawable="@drawable/button_normal" />
</ripple>
Comments
Post a Comment