Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 439
Orcun Sevsay Avatar asked Mar 09 '15 21:03

Orcun Sevsay


People also ask

What is a fragment in Android?

Fragments. A Fragment represents a reusable portion of your app's UI. A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events. Fragments cannot live on their own--they must be hosted by an activity or another fragment. The fragment’s view hierarchy becomes part of, or attaches to , ...

What's new in Android fragmentscenario?

FragmentScenario has been fully converted to Kotlin while maintaining source and binary compatibility via usage of Kotlin 1.4's functional interfaces for FragmentAction. ( I19d31) FragmentContainerViews that do not inflate a fragment using the class or android:name attribute can now be used outside of a FragmentActivity.

What is new in fragmentmanager API?

Fragment Result API: Added support for passing results between two Fragments via new APIs on FragmentManager. This works for hierarchy fragments (parent/child), DialogFragments, and fragments in Navigation and ensures that results are only sent to your Fragment while it is at least STARTED.

How to set Max lifecycle state for a fragment in Android?

androidx.fragment:fragment:1.1.0-alpha07, androidx.fragment:fragment-ktx:1.1.0-alpha07, and androidx.fragment:fragment-testing:1.1.0-alpha07 are released. The commits included in this version can be found here. You can now set a max Lifecycle state for a Fragment by calling setMaxLifecycle () on a FragmentTransaction.


1 Answers

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.

like image 177
Orcun Sevsay Avatar answered Nov 15 '22 05:11

Orcun Sevsay