网上大多数介绍的实现方式就是在styles.xml中添加 name="android:windowFullscreen">true
这个属性,但是自己按照操作不好使,后来自己尝试去做一下,总结方法如下代码

Dialog dialog = new Dialog(this, R.style.Dialog);dialog.show();LayoutInflater inflater = LayoutInflater.from(this);View viewDialog = inflater.inflate(R.layout.adapter_list, null);Display display = this.getWindowManager().getDefaultDisplay();int width = display.getWidth();int height = display.getHeight();//设置dialog的宽高为屏幕的宽高ViewGroup.LayoutParams layoutParams = new  ViewGroup.LayoutParams(width, height);dialog.setContentView(viewDialog, layoutParams);

主要重要的步骤就是设置Dialog的宽高为屏幕的宽高,这样就可以实现Dialog的全屏显示。

转载于:https://www.cnblogs.com/guilin-hu/p/5798421.html

更多相关文章

  1. android:layout_weight属性
  2. TextView属性大全+单行显示长文本
  3. 【Android 基础】TextView的属性详解
  4. [置顶] Android屏幕适配全攻略
  5. Android权限安全(5)组件的android:exported属性

随机推荐

  1. GridView
  2. 设置透明,模糊,黑暗度
  3. android aosp 下载源代码
  4. android中关于margin的一些注意点
  5. (20120722)(笔记002)android开发环境搭建
  6. Android资料备注
  7. android:padding 与 android:margin的区
  8. [图解]Android下Invalid layout of java.
  9. Android 软键盘遮挡Dialog
  10. 错误:AGPBI: {“kind“:“error“,“text