//获取虚拟按键的高度 public static int getNavigationBarHeight(Context context) { int result = 0; if (hasNavBar(context)) { Resources res = context.getResources(); int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "androi
方法一: //获取手机状态栏高度 public static int getStatusBarHeight(Context context){ Class<?> c = null; Object obj = null; Field field = null; int x = 0, statusBarHeight = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(
1 public static int getStatusBarHeight(Context context){ 2 Class<?> c = null; 3 Object obj = null; 4 Field field = null; 5 int x = 0, statusBarHeight = 0; 6 try { 7 c = Class.forName("com.andr
方法一: DisplayMetrics metrics=new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width=metrics.widthPixels;//屏幕的宽度 int height=metrics.heightPixels;//屏幕的高度 方法二: Display display=getWindowManager.getDefaultDisplay(); Poi
获取状态栏高度 一.传统方式:有时获取为0,解决方法看 二 1 2 3 4 代码 Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; 二.4.0.3之后可能获取为0 public int getBarHeight(){ Class<?> c = null; Objec