Here is my button appearance :
Which is actually defined by :
<Button
style="@style/Button.Pressed"
android:id="@+id/standardRestock"
android:layout_width="165dp"
android:layout_height="70dp"
android:backgroundTint="@color/button_checked_style"
android:fontFamily="@font/pragatinarrow"
android:text="@string/standard"
android:textAllCaps="true"
android:textColor="@color/black"
android:textSize="24sp" />
My style is defined by :
<style name="Button.Pressed" parent="android:Widget.Button">
<item name="android:background">@drawable/dp_button_checked</item>
<item name="android:textColor">@color/black</item>
</style>
My background is currently defined by :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@color/grey_button_checked" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@color/grey_button_checked" />
<item android:drawable="@color/grey_button">
<shape>
<stroke
android:width="5dp"
android:color="@color/redcheckborder" />
<corners
android:radius="4dp"/>
</shape>
</item>
</selector>
In short, my button should be grey and red, but AS decide to keep the default colorPrimary.
Uh, and i tried to change android:background to backgroundTint, keep the same.
What did I miss ?
PS : "@color/button_checked_style" looks like that :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/grey_button" android:state_checked="false" />
<item android:color="@color/redcheckborder" android:state_checked="true" />
</selector>
2
Answers
Found...Use AppCompat Button, the current one isn't modify allowed.
instead of
and
in the XML drawable file
You have to change the line android:state_checked="false" from "false" to "true"