ダイアログを透過状態で表示するのはどうしたらいいのですか

1,015 views
Skip to first unread message

Spock

unread,
Jun 9, 2014, 9:10:16 AM6/9/14
to android-g...@googlegroups.com
ダイアログを透過状態(背後にあるactivityが透けて見える状態)で表示するのはどうしたらいいのですか

dialogのクラスを次のようにしました。
public class Dialog extends DialogFragment {
    @Override
    public android.app.Dialog onCreateDialog(Bundle savedInstanceState) {
        View layout = getActivity().getLayoutInflater().inflate(R.layout.dialog,null);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setView(layout);
        AlertDialog dialog =builder.create();
①      dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return dialog;
    }
}

R.layout.dialog.xmlでは、
②親(ルート)の<LinearLayoutのタグで   android:background="#31ff0000" としたり
③<shape のdrawableを作って、そこのsolidのcolorに"#31ff0000"を設定して、このdrawableをbackgroundに設定したり
④次のスタイルを作って、これを設定したり
        <style
            name="Theme.CustomProgressDialog"
            parent="android:style/Theme.Dialog">

            <item name="android:windowBackground">@android:color/transparent</item>

        </style>
しました。
 しかし、ダイアログの背景自体は、白色のままなのか、透過状態になりません。
 
ダイアログは、
        AlertDialog dialog =builder.create();
のdialogの上に、
        View layout = getActivity().getLayoutInflater().inflate(R.layout.dialog,null);
が乗っかるというようなことなのでしょうか?
そして、①は、dialogを透過にするということですか?
layout自体の透過はどのようにするのですか?

Spock

unread,
Jun 9, 2014, 9:13:39 AM6/9/14
to android-g...@googlegroups.com
R.layout.dialog.xmlの親(ルート)のLinearLayoutのalphaの設定も試しました
Reply all
Reply to author
Forward
0 new messages