Why does changing the color of the Default button make it look RECTANGLE in Android?

Why does changing the default button color make it look RECTANGLE? I do not want to use custom background images for this. I want to do this programmatically for several conditions under which I change the colors of many small buttons on the screen. Can anyone give a solution?

PS ==> There seems to be no workaround by reading this http://groups.google.com/group/android-beginners/browse_thread/thread/e1313e2c98e9c52b

or is there?

+5
source share
2 answers

To change the color:

Drawable d = findViewById(R.id.button_name).getBackground();
               PorterDuffColorFilter filter = new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
               d.setColorFilter(filter);

To remove color:

Drawable d = findViewById(R.id.button_name).getBackground();
               findViewById(R.id.button_name).invalidateDrawable(d);
               d.clearColorFilter();
+8
source

XML script Assiging colors backgroud. , Button , , , , - . backgroud, stype/theme , , / . , XML-. .xml android. .XML . , ...

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff"/>
    <corners android:radius="6dp"/>
    <padding android:left="3dp" android:top="2dp"
            android:right="3dp" android:bottom="2dp" />
</shape>
+1

All Articles