Issue
To include ripple effect for my ImageButton I created drawable-v21 folder in res and added the following code
ans_go_btn.xml :-
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#c20586">
<item>
<shape android:shape="oval">
<solid android:color="#fa09ad"/>
</shape>
</item>
</ripple>
</selector>
and in drawable directory I have the below code.
ans_go_btn.xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="oval" >
<solid android:color="@color/black"></solid>
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="oval" >
<solid android:color="@color/light_blue"></solid>
</shape>
</item>
<item >
<shape android:shape="oval" >
<solid android:color="@color/blue_app"></solid>
</shape>
</item>
</selector>
Image button has android:background="@drawable/ans_go_btn"
attribute.
In kitkat device the ImageButton appears but, not in my Lollipop device. I might be doing some clear mistakes, but I'm not being able to find it out. Please help!
Thanks
Solution
First of all, the ans_go_btn in drawable-v21 should be:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple
android:color="#c20586">
<item>
<shape android:shape="oval">
<solid android:color="#fa09ad"/>
</shape>
</item>
</ripple>
</item>
</selector>
Selector should have item, other than ripple.
Then, you can change the attribute of the item.
Answered By - xxxzhi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.