Android Dialog全屏显示


网上大多数介绍的实现方式就是在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的全屏显示。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM