相关疑难解决方法(0)

Android警报对话框用另一种颜色替换默认蓝色

我正在使用单选警告对话框,我想将默认蓝色(标题行和单选按钮)替换为我在标题栏中使用的橙色.我能够改用标题栏setCustomTitle(),但我迷失了试图摆脱这个该死的蓝色.

对于标题栏

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/orange" >

    <TextView
        android:id="@+id/alertTitle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="14dp"
        android:gravity="center"
        android:text="Alert Title"
        android:textColor="@color/white"
        android:textSize="18sp" />    

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

构建AlertDialog

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
View customTitle = View.inflate(MainActivity.this, R.layout.custom_alert_title, null);
builder.setCustomTitle(customTitle);
builder.setSingleChoiceItems(mAlertOptions, -1, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {                    
        // do stuff
        dialog.dismiss();
    }
}).create().show();
Run Code Online (Sandbox Code Playgroud)

这就是它的样子

在此输入图像描述

我需要摆脱这个蓝色!救命!

android android-layout android-alertdialog

4
推荐指数
1
解决办法
6336
查看次数