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

ビューをビルダーに設定すると、この灰色の線が上下に作成されます。代わりに、setView を dialog.like dialog.setView(layout,0,0,0,0); に設定すると、レイアウトがダイアログ全体にバインドされます。

于 2012-07-10T13:42:43.517 に答える
0

別のオプションはandroid:background="@android:color/white"、レイアウトから削除することです。次に、警告ダイアログのデフォルトの明るい灰色がかった背景が均一になります。(暗いテーマで逆を強制したため)少なくとも見栄えがよく、手間をかける価値があります. ちょうど私の2セント。

于 2013-08-20T14:00:31.353 に答える