Currently, the ImageButton
have set android:background="@drawable/mem_btn",
mem_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 xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="0dp" android:color="@color/black" />
<solid android:color="@color/pressed"/>
<padding android:left="5dp" android:top="5dp"
android:right="5dp" android:bottom="5dp" />
<corners android:radius="14dp" />
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="0dp" android:color="@color/black" />
<solid android:color="#3366CC"/>
<padding android:left="5dp" android:top="5dp"
android:right="5dp" android:bottom="2dp" />
<corners android:radius="14dp" />
</shape>
</item>
</selector>
The above works perfectly.
Question:
I would like to let the user change the background color: i.e. other colors upon users' choice, yet with the pressed_color, radius remain unchanged.
In this case, how to set the information in the xml programmatically such that the color for the non-pressed state is a variable?
Thanks!