0

It is a code that I wrote in my drawable folder, but it won't work either.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape>
            <solid android:color="#EF9191" />
            <corners android:radius="8dp" />
        </shape>
    </item>

    <item android:state_pressed="false">
        <shape>
            <solid android:color="#ED3939" />
            <corners android:radius="8dp" />
        </shape>
    </item>
</selector>
Vishal Vasani
  • 647
  • 8
  • 16
Sami
  • 1
  • 1

2 Answers2

0

You can either change the color programmatically or use a selector. If you use a selector, make sure to use the correct state as described here.

Also, see an example that might help here.

0

Use this in XML of Button tag to change background instead of android:background="#D33636"

app:backgroundTint="#D33636"

Although, you need to define app in the parent layout as well:

xmlns:app="http://schemas.android.com/apk/res-auto"
Abu bakar
  • 751
  • 1
  • 4
  • 16