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.
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 , ...
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With