Android的ResideMenu库,片段的底部有裁剪问题片段、问题、Android、ResideMenu

2023-09-05 03:02:44 作者:墨染倾城

https://m.xsw88.com/allimgs/daicuo/20230905/860.png?DL = 0

本图片由承上启下5捕获正如你可以看到顶部和屏幕底部之间的差距是不同的。当侧菜单关闭Android的标志被裁剪。屏幕下方的部分是根据本地导航栏隐藏起来。

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://m.xsw88.com/allimgs/daicuo/20230905/861.png?DL = 0

在另一方面,此图象是通过星系S5迷你捕获。可能注意到顶端之间和下面的间隙的画面是相同的量。这是没有问题的。

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.

有相同ResideMenu库与不同的设备和Android操作系统(棒棒糖&安培;奇巧)。我看的布局(residemenu.xml)找到一些错误的;但一切似乎是正确的我。我找不到任何解决这个问题。有没有什么办法来解决,以正确缩放主片段(从顶部和底部相同的保证金)?请帮我。

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.

链接库:github.com/SpecialCyCi/AndroidResideMenu

link to library: github.com/SpecialCyCi/AndroidResideMenu

编辑:

此链接是我的问题说起它的解决方案。

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

推荐答案

我在ResideMenu库编辑的方法ResideMenu.java解决了这个问题。

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

我做了一个名为fitSystemWindows的方法有一些变化

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

在我所做的更改:

 @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;
    }

在我所做的更改:

@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.