How To Set Button Color In Dialog Box
i have created a dialog box which has 'accept' and 'reject' buttons, but the color of the button is in default color. can anyone provide the code to set the color of the buttons in
Solution 1:
By creating a custom drawable.. for example..
button.setBackgroundResource(R.drawable.custom_button);
custom_button.xml
<?xml version="1.0" encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android" ><item><shapeandroid:shape="rectangle"><cornersandroid:radius="8dip" /><strokeandroid:width="1dp"android:color="your color" /><solidandroid:color="@color/ceruleo" /></shape></item><itemandroid:top="1dp"android:bottom="1dp"android:left="1dp"android:right="1dp"><shapeandroid:shape="rectangle"><cornersandroid:radius="8dip" /><strokeandroid:width="1dp"android:color="your color" /><solidandroid:color="@color/ceruleo" /></shape></item></layer-list>
Solution 2:
Buttonb= dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
if(b != null)
b.setBackgroundColor(Color.BLUE);
This Code will help you. You can set color to Negative or positive button as you wish.
Solution 3:
ANother way is , you can create dialogue activity for custom dialogues. just create activity and in manifest
android:theme="@android:style/Theme.Dialog
create layout for this. by this way you can create any design you want
Post a Comment for "How To Set Button Color In Dialog Box"