I have a button with ripple effect, it has two states one is "regular" with ripple effect and the other one is selected the background is changed but there are two issues:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@color/cal_selected"/>
<item android:drawable="@drawable/cal_day_regualr">
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorActivatedHighlight">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@color/cal_background" />
</shape>
</item>
</ripple>
</item>
</selector>
I managed to accomplish this by adding another ripple to selected state see the code below:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<ripple android:color="@color/cal_selected_ripple">
<item>
<shape android:shape="oval">
<solid android:color="@color/cal_selected" />
</shape>
</item>
</ripple>
</item>
<item>
<ripple android:color="?android:attr/colorActivatedHighlight">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@color/cal_background" />
</shape>
</item>
</ripple>
</item>
</selector>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.