相关疑难解决方法(0)

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)

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

在此输入图像描述

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

java android background-color android-alertdialog

2
推荐指数
1
解决办法
1万
查看次数