Android获取屏幕尺寸大小代码实例
程序员文章站
2022-08-17 19:29:10
@override
protected void oncreate(bundle savedinstancestate) {
super.oncreat...
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //获取屏幕的长度和宽度 displaymetrics dm = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(dm); int width = dm.widthpixels; int heigh = dm.heightpixels; dialog d = new dialog(this); d.settitle(width + "*" + heigh); d.show(); }