2

对话框布局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>

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

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();

以及我在测试时看到的:

在此处输入图像描述

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

4

3 回答 3

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);
    }
}
于 2012-11-29T12:17:06.863 回答
1

嘿,将您的视图设置为 builder 会在顶部底部创建这条灰线,而不是您可以将 setView 设置为您的 dialog.like dialog.setView(layout,0,0,0,0);它将您的布局绑定到整个对话框。

于 2012-07-10T13:42:43.517 回答
0

另一种选择是android:background="@android:color/white"从您的布局中删除。然后警报对话框将统一具有其默认的浅灰色背景。(因为您在黑暗主题上强制反转)至少它看起来不错并且值得麻烦。只是我的两分钱。

于 2013-08-20T14:00:31.353 回答