BottomSheet
BottomSheet copied to clipboard
Behind navigation bar
Hey, nice library. I do see something wierd with a transparent navigation bar. On my Nexus7 the sheet does the correct thing and adds padding to the sheet bottom. On my OneplusOne the sheet doesn't do the correct thing and make the sheet overlap with the navigation bar :(
My statusbar height implementation works on all my activities. Could you compare it with yours?
private static boolean hasNavBar(Context context) {
// Kitkat and less shows container above nav bar
if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return false;
}
// Emulator
if (Build.FINGERPRINT.startsWith("generic")) {
return true;
}
boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
boolean hasNoCapacitiveKeys = !hasMenuKey && !hasBackKey;
Resources resources = context.getResources();
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
boolean hasOnScreenNavBar = id > 0 && resources.getBoolean(id);
return hasOnScreenNavBar || hasNoCapacitiveKeys || getNavigationBarHeight(context, true) > 0;
}
public static int getNavigationBarHeight(Context context, boolean skipRequirement) {
int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0 && (skipRequirement || hasNavBar(context))) {
return context.getResources().getDimensionPixelSize(resourceId);
}
return 0;
}
I believe there are some changes in android 7.0. The workaround would be if the current android version >=7 has NavBar return false, unfortunately I don't have android 7 device so I can't test it, would you mind testing it and sending a PR to me ? Thanks
I Checked it by changing
mDialogView.getChildAt(0).setPadding(0, 0, 0, helper.mNavBarAvailable ? helper.getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0);
to
mDialogView.getChildAt(0).setPadding(0, 0, 0, ActivityUtils.getNavigationBarHeight(getContext(), false));
at BottomSheet.java:198.
This fixed the issue for me :D
I've never done a PR before, so I'm not quite sure how to do it :p
Pull request filed :D