API 22. I want to set a border radius for my button, so I did this: How to make the corners of a button round? (I tried out the answer that is ticked as correct). How to change the color of a button? None of the methods here work either. I used to set the background color of my button with android:backgroundTint. That was the only method working. Unfortunately, when I link the file to my button via android:background="@drawable/roundbutton", the color that I selected via android:backgroundTint wont work. As well as the solid color I defined int the drawable/roundbutton. Strangely the border Radius works: My Code in activity_main.xml:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/signinotherbutton"
android:background="@drawable/roundbutton"
android:backgroundTint="@color/grey"
android:textColor="@color/white"
android:textAllCaps="false"/>
My Code for the drawable/roundbutton.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<solid android:color="@color/grey"/>
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<solid android:color="@color/grey"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<solid android:color="@color/grey"/>
</shape>
</item>
</selector>
Result: Button with the Radius I defined, but with the default color (ca. purple) No, @color/grey is definitely grey, not purple. Thanks for all answers