Android:更改自定义AlertDialog背景

Pau*_*kis 2 java android background-color android-alertdialog

对话框布局xml:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/root_view"
     android:padding="3dp"
     android:background="@android:color/white"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content" >

     //...content...

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

在图钉上点击时,地图叠加中的对话框实现:

AlertDialog.Builder builder;

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.map_kap_dialog,
                    (ViewGroup) mapView.findViewById(R.id.root_view));

//prepare info to show...
//info prepared

//other preparations stuff
builder = new AlertDialog.Builder(context);
builder.setView(layout);
dialog = builder.create();
dialog.setInverseBackgroundForced(true);
dialog.setCanceledOnTouchOutside(true);
//show it
dialog.show();
Run Code Online (Sandbox Code Playgroud)

以及我在测试时看到的内容:

在此输入图像描述

所以我希望对话框周围的浅灰色背景(方形白色空间周围)变为白色,所以它看起来不会那么难看.谁能帮我?

Can*_*ner 9

我有同样的问题,我设法使用这样的自定义对话框修复它:

public class CustomDialog extends Dialog {
    public CustomDialog(Context context, View view) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(view);
        getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);
    }
}
Run Code Online (Sandbox Code Playgroud)