Android获取屏幕尺寸大小代码实例
程序员文章站
2022-04-30 22:55:39
@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(); }