This is for api < 21
<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" android:shape="oval">
<size
android:width="60dp"
android:height="60dp" />
<solid android:color="#007fa9" />
</shape>
</item>
<item android:id="@+id/shape_id" >
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<size
android:width="60dp"
android:height="60dp"
/>
<solid android:color="#007fa9" />
</shape>
</item>
</selector>
As you see I have a selector with states inside and also shapes, How can I change the solid color of the shape programatically? I'm setting this as the background of a Relative Layout, so it behaves like a button changing its color when it's pressed, or maybe there's a way to create a shape programatically, if so how?
For api 21 and above
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#007fa9">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="#007fa9" />
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="60dp"
android:height="60dp" />
<solid android:color="#007fa9" />
</shape>
</item>
</ripple>
How do you do it for this one?