Android 如何更改AlertDialog按钮面板(操作按钮后面的区域)的颜色?

Android 如何更改AlertDialog按钮面板(操作按钮后面的区域)的颜色?,android,android-alertdialog,background-color,Android,Android Alertdialog,Background Color,我的应用程序显示一个AlertDialog page1WalkthroughDialogBuilder = new AlertDialog.Builder(activity, R.style.Widget_AppCompat_Light_ActionBar); page1WalkthroughDialogBuilder .setCancelable(false) .setView(page1WalkthroughDialog

我的应用程序显示一个AlertDialog

        page1WalkthroughDialogBuilder = new AlertDialog.Builder(activity, R.style.Widget_AppCompat_Light_ActionBar);
    page1WalkthroughDialogBuilder
            .setCancelable(false)
            .setView(page1WalkthroughDialogLayout)
            .setPositiveButton(getString(R.string.goto_next), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    page2Walkthrough.show();
                    dialog.cancel();
                }
            })
            .setNegativeButton(getString(R.string.exit_dialog), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    manager.beginTransaction().show(LaunchActivity.editProfileFragment).commit();
                    dialog.cancel();
                }
            });

    page1Walkthrough = page1WalkthroughDialogBuilder.create();
它使用以下布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rel_layout"
    android:layout_height="match_parent"
    android:background="@drawable/park_with_people"
    mlns:android="http://schemas.android.com/apk/res/android">
<TextView
    android:id="@+id/heading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:textStyle="bold"
    android:text="@string/welcome_hdr"
    android:textSize="35sp"
    android:layout_marginTop="10dp"
    android:layout_marginStart="10dp" />

<uomini.com.wegrokstrasbourg.TextViewWithImages
    android:id="@+id/body"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/heading"
    android:text="@string/welcome_text"
    android:textSize="20sp"
    android:layout_marginTop="10dp"
    android:layout_marginEnd="10dp"
    android:layout_marginStart="10dp" />
</RelativeLayout>

除了按钮有白色背景外,所有内容都显示得很好:


如何更改背景的颜色?

您应该创建一个样式,然后将其应用到构建器构造函数中:

<style name="MyTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:background">@color/myColor</item>
</style>

在StylesUp中覆盖此样式
R.style.Widget\u AppCompat\u Light\u ActionBar
,这是答案只是一个注意:此属性更改整个对话框中的背景颜色,而不仅仅是按钮栏。工作非常完美。万分感谢!我已经设置了背景,但这并没有覆盖它。
AlertDialog alertDialog = new AlertDialog.Builder(getContext(), R.style.MyTheme)
    ...
    ...
    .create();