Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling view hide problem below navigation Bar #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niteshsirohi1
Copy link

@niteshsirohi1 niteshsirohi1 commented Feb 22, 2017

Change this method in ResideMenu class

   @Override
    protected boolean fitSystemWindows(Rect insets) {
    // Applies the content insets to the view's padding, consuming that
    // content (modifying the insets to be 0),
    // and returning true. This behavior is off by default and can be
    // enabled through setFitsSystemWindows(boolean)
    // in api14+ devices.
    Point appUsableSize = getAppUsableScreenSize(mContext);
    Point realScreenSize = getRealScreenSize(mContext);

    boolean hasBackKey=false;
    // navigation bar at the bottom
    if (appUsableSize.y < realScreenSize.y) {
        hasBackKey=true;
    }
   // This is added to fix soft navigationBar's overlapping to content above LOLLIPOP
    int bottomPadding = viewActivity.getPaddingBottom() + insets.bottom;

    if (hasBackKey ) {//there's a navigation bar
        bottomPadding += getNavigationBarHeight();
    }

    this.setPadding(viewActivity.getPaddingLeft() + insets.left,
            viewActivity.getPaddingTop() + insets.top,
            viewActivity.getPaddingRight() + insets.right,
            bottomPadding);
    insets.left = insets.top = insets.right = insets.bottom = 0;
    return true;
}

And these methods

    public static Point getAppUsableScreenSize(Context context) {
    WindowManager windowManager = (WindowManager)   context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;
 }

  public static Point getRealScreenSize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= 17) {
        display.getRealSize(size);
    } else if (Build.VERSION.SDK_INT >= 14) {
        try {
            size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
            size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
        } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {}
    }

    return size;
}

@Nik2505
Copy link

Nik2505 commented Mar 4, 2019

What to do for Android P Navigation gesture thing. In that I am not getting App Usable Screen Size and Real Screen Size same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants