Android获取屏幕宽高的方法
16lz
2022-06-16
private int width,height;方法一: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); width = dm.widthPixels; height = dm.heightPixels;方法二: Display display = getWindowManager().getDefaultDisplay(); width = display.getWidth(); height = display.getHeight();
Service 中获取的方法:
DisplayMetrics dm = new DisplayMetrics(); dm = name.this.getApplicationContext().getResources().getDisplayMetrics(); width = dm.widthPixels; height = dm.heightPixels;
更多相关文章
- android的ndk修改app_platform的方法,亲测绝对可行
- android调用NotificationManager.notify无效,通知栏不显示
- Android权限
- android隐藏以及显示软键盘以及不自动弹出键盘的方法
- Android(安卓)Keep screen on(保持屏幕唤醒)
- Android获取系统的内存使用率
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用
- python list.sort()根据多个关键字排序的方法实现