Android ResideMenu library, bottom of Fragment has Cropping issue

前端 未结 4 1365
礼貌的吻别
礼貌的吻别 2020-12-20 22:01

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 diff

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 22:09

    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.

提交回复
热议问题