Reference:
https://gist.github.com/hamakn/8939eb68a920a6d7a498
Code snippet:
public static int getStatusHeight(Context context) { int statusBarHeight = -1; try { Class<?> clazz = Class.forName("com.android.internal.R$dimen"); Object object = clazz.newInstance(); int height = Integer.parseInt(clazz.getField("status_bar_height").get(object).toString()); statusBarHeight = context.getResources().getDimensionPixelSize(height); } catch (Exception e) { e.printStackTrace(); } return statusBarHeight; }
沒有留言:
張貼留言