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

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的全屏显示。

相关文章:

  • 2021-12-08
  • 2022-01-20
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-11-10
  • 2022-01-05
  • 2022-12-23
  • 2022-02-11
  • 2022-01-07
  • 2021-08-01
相关资源
相似解决方案