androidandroid-fragmentsandroid-5.0-lollipopnexus-5residemenu

Android ResideMenu library, bottom of Fragment has Cropping issue


https://www.dropbox.com/s/lykyutdlo6386il/nexus%205%202.png?dl=0

This picture is captured by nexus 5. As you can see the gap between top and bottom of screen is different. Android Logo is cropped when the side menu is closed. Part of the bottom screen is hidden under native navigation bar.

https://www.dropbox.com/s/wcwuat1bwoqa26v/correct1.png?dl=0

On the other hand, this picture is captured by galaxy s5 mini. You may notice the gap between top and below of the screen is the same amount. There is no problem at all.

It is the same ResideMenu library with different devices and android OS (lollipop & kitkat). I look at the layouts (residemenu.xml) to find something wrong; but everything seems correct to me. I couldn't find any solution to this problem. Is there any way to fix to scale main fragment correctly (same margin from top and bottom)? Please help me.

link to library: github.com/SpecialCyCi/AndroidResideMenu

Edit:

This link is the issue that I'm talking about with it's solution.


Solution

  • I solved this issue by editing a method "ResideMenu.java" in ResideMenu library.

    I made a few changes in a method called "fitSystemWindows"

    before I made changes:

     @Override
        protected boolean fitSystemWindows(Rect insets) {
    
            this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top,
                    viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + insets.bottom);
            insets.left = insets.top = insets.right = insets.bottom = 0;
            return true;
        }
    

    after I made changes:

    @Override
        protected boolean fitSystemWindows(Rect insets) {
            int bottomPadding=insets.bottom;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Resources resources = getResources();
                int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
                if (resourceId > 0) {
                    bottomPadding += resources.getDimensionPixelSize(resourceId);
                }
            }
            this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top,
                    viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + bottomPadding);
            insets.left = insets.top = insets.right = insets.bottom = 0;
            return true;
        }
    

    This change solve my issue, part of the bottom screen hidden under native navigation bar.

    I hope this solution be helpful anyone who encounter this kind of issue. Cheers.