我拥有一台能够隐藏导航栏的HTC One A9手机。在我的应用程序中,我需要获取导航栏的高度并设置相应的填充。现在出现了一个问题:当我隐藏导航栏时,仍然设置填充(即使Snapchat也有这个问题)。我的问题是:是否有其他代码可以替代这个代码使其工作?
public static int getNavBarHeight(Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
谢谢你的帮助!
android:windowTranslucentNavigation
。 - shaktiman_droid