
获取Android手机屏幕的高度
- /**
- * 获取状态栏高度
- *
- * @param context 上下文
- * @return 高度
- */public static int getStatusBarHeight(Context context) {
- int result = 0;
- int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
- if (resId > 0) {
- result = context.getResources().getDimensionPixelSize(resId);
- }
- return result;}
- /**
- * 获取导航栏高度
- *
- * @param context 上下文
- * @return 高度
- */public static int getNavigationHeight(Context context) {
- int resourceId = 0;
- int rid = context.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
- if (rid != 0) {
- resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
- return context.getResources().getDimensionPixelSize(resourceId);
- } else{
- return 0;
- }}
评价
排名
31
文章
25
粉丝
11
评论
6
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术