1

ここで別の回答のコードを使用しています:

 AlertDialog.Builder adb = new AlertDialog.Builder(this);
    Dialog d = adb.setView(new View(this)).create();
    // (That new View is just there to have something inside the dialog that can grow big enough to cover the whole screen.)

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(d.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    d.show();
    d.getWindow().setAttributes(lp);

alertDialog を全画面表示にするのは本当に便利だと思いますが、色は、黒いテキストの白い背景ではなく、白いテキストの黒い背景になります。このコードがどのように色を変えるのかわかりません。誰でも情報を提供できますか?

4

1 に答える 1

0

行で:

Dialog d = adb.setView(new View(this)).create();

Viewデフォルトで黒の背景になる新しいものを作成します。

次に、このビュー属性をどこでも使用します。

lp.copyFrom(d.getWindow().getAttributes());
d.getWindow().setAttributes(lp);

解決:

新しいビューを作成したら、背景を設定します。

View view = new View(this);
view.setBackgroundColor(...);
Dialog d = adb.setView(view).create();

よろしく。

于 2012-11-23T01:29:18.850 に答える