自定义Dialog实现全屏和位置在屏幕底部

  
  
  
  
// 设置dialog宽度全屏
WindowManager windowManager = this.getWindow().getWindowManager();
Display display = windowManager . getDefaultDisplay ();
WindowManager . LayoutParams lp = this . getWindow (). getAttributes ();
lp . width = ( int ) ( display . getWidth ()); // 设置宽度
this . getWindow (). setAttributes ( lp );
this . getWindow (). getDecorView (). setPadding ( 0 , 0 , 0 , 0 ); // 默认Theme.Dialog还是存在padding的
this . getWindow (). setGravity ( Gravity . BOTTOM );
this . getWindow (). setWindowAnimations ( R . style . TimePickDialog );// 设置dialog显示动画

你可能感兴趣的:(自定义Dialog实现全屏和位置在屏幕底部)