alert Dialog set button color rounded corners

button.setBackground(ContextCompat.getDrawable(LauncherNoticeActivity.this,R.color.button_background));
<resources>
    <style name="AlertDialogCustom" parent="Theme.AppCompat.DayNight.Dialog.Alert">
        <item name="android:background">@color/view_background</item>  dialog的背景
        <item name="android:dialogCornerRadius">10dp</item>            对话框的四个圆角半径
        <item name="android:buttonCornerRadius">10dp</item>            button的四个圆角半径
    </style>
</resources>
button.setBackgroundResource(R.drawable.button_background);
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners android:radius="10dp"/>
    <size android:width="100dp" android:height="10dp"/>
    <solid android:color="@color/button_background"/>
</shape>

Guess you like

Origin blog.csdn.net/xiaowang_lj/article/details/129022901