how to set margin in Dialog

后端 未结 6 1350
情歌与酒
情歌与酒 2020-12-16 17:25

I have used Dialog for display ad in my Andorid app.But I have to display this Dialog about 50dp top from buttom so i think we should set Dia

6条回答
  •  伪装坚强ぢ
    2020-12-16 17:56

    View view = layoutInflater.inflate(R.layout.dialog_layout, null);
            AlertDialog infoDialog = new AlertDialog.Builder(this)
            .setView(view)  
            .create();
            Window window =infoDialog.getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND );
            WindowManager.LayoutParams wlp = window.getAttributes();
            wlp.gravity = Gravity.BOTTOM;
            wlp.dimAmount=(float) 0.0;
            //wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND ;
    
            window.setAttributes(wlp);
            infoDialog.show();
    

    Change gravity to bottom

提交回复
热议问题