android 代碼如何設置AlertDailog背景不變暗?

 

java代碼中利用WindowManager設置自定義Dialog背景,

LayoutInflater inflater = LayoutInflater.from(this);

View layout = inflater.inflate(R.layout.androiddialog_layout, null);

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builider.setView(layout);

builder.setCancelable(true);

final AlertDialog dialog = builder.show();

WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
        params.width = 600;
        params.height = 300;
        params.dimAmount = 0.0f;   //主要這裏設置不變暗
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
       dialog.getWindow().setAttributes(params);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章