I have a custom background defined on the drawable folder that basically makes a rounded shape.
The problem that I'm facing is when I click on the button, the button "loses" the custom background and get a default one of Android.
I have tried creating a selector and adding those items with state_focused and so like this on but nothing works.
Is there an easy way to avoid Android changing the background of a button when clicking on it?
This is my button before the click:
And this is my button after the click:
Here is the axml with the button code:
<Button
android:id="@+id/lockDeviceButton"
android:text="@string/lockThisDevice"
android:textColor="@android:color/white"
android:background="@drawable/button_rounded_green"
android:drawableLeft="@drawable/icon_lock"
/>
Here is the rounded layout:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="24dp" />
<solid android:color="#03ae50" />
</shape>
And here is what I have tried so far to keep the same background for the states:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states
-->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/rounded_corners" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/rounded_corners" />
<!-- Focused states
-->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/rounded_corners" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/rounded_corners" />
<!-- Pressed
-->
<item android:state_pressed="true" android:drawable="@drawable/rounded_corners" />
</selector>