2

I am trying to change the style of android default buttons. I have created an xml file in the drawable folder in res folder called custom_button.xml and have referenced it in the xml layout file, however when I run the application, the button style has not changed and instead I have lost the outline of the original button.

custom_button.xml

<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    <solid
        android:color="#FF0000" /> 
</shape>    

main.xml

 <TextView
        android:id="@+id/textView1"
        android:layout_width="85dp"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textColor="#6600ff"
        android:text="" />

    <Button
        android:id="@+id/button_getDraw"
        style="?android:attr/buttonStyleSmall"
        android:background="@drawable/custom_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_getDraw"
        android:onClick="getLotteryDrawFromWebsite" />

    <Button
        android:id="@+id/check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_check"
        android:onClick="checkNumbers"
        android:enabled="false" /> 

Whats the problem? Thx in advance..

2 Answers 2

3

Change your custom_button xml to this .

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle">

<solid android:color="#FF0000"/>

Sign up to request clarification or add additional context in comments.

Comments

0

Try using this link.... also you set button selection effect.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.