Android--获取标题栏,状态栏,屏幕高度
16lz
2021-01-23
获取状态栏高度
Rect frame = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
获取actionBar的高宽度
有一个属性:
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
获取屏幕高度,宽度
DisplayMetrics dm = newDisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);//this指当前activity
screenWidth =dm.widthPixels;
screenHeight =dm.heightPixels;
当然,开发完APP也是需要进行全方位的检测:www.ineice.com
更多相关文章
- android获取控件宽度
- Android精准的获取底部虚拟键盘的高度
- ListView中Item高度设置
- Android——UI篇:动态设置DiaLog高度
- Android WebView内容宽度自适应
- android中监听软键盘的弹出与隐藏,并获取软键盘的高度
- android 获取状态栏高度
- Android 四种获取屏幕宽度的方法总结