First create the shapes:
Shape of Button (normal):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:startColor="#2e8fc2"
android:endColor="#006599"
/>
<stroke
android:width="2dp"
android:color="#00679e"
/>
<corners
android:radius="3dp"
/>
</shape>
And after the button when pressed:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#254683"
android:endColor="#1f2f61"
/>
<stroke
android:color="#000000"
android:width="2dp"
/>
<corners
android:radius="3dp"
/>
</shape>
And then create a selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/botao_seleccionado"
/>
<item
android:drawable="@drawable/botao"
/>
</selector>
And lastly, go to the code (.xml) of the button that will receive these backgrounds and add the following:
android:background="@drawable/seleccionador"
Thanks for your help, but I’ve just seen a few more things I’ll have to do here. So how could I make this change using Swit?
– carlos giovani casilo
What would Swit be?
– Leonardo Dias