Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space at the bottom of devices #154

Open
ghost opened this issue Feb 20, 2019 · 7 comments
Open

Space at the bottom of devices #154

ghost opened this issue Feb 20, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Feb 20, 2019

Space at the bottom of devices which are either flagship or new android phones .
Especially those devices where you can hide the navigation bar from settings and navigate through gesture.

@ghost
Copy link
Author

ghost commented Feb 28, 2019

screenshot_2019-02-28-12-09-43-061_com sogo sogosurvey - copy
screenshot_2019-02-28-12-09-38-045_com sogo sogosurvey - copy

@ghost
Copy link
Author

ghost commented Feb 28, 2019

`<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">



    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:fitsSystemWindows">true</item>
</style>`

This property works for normal Navigation menu, but not supporting while using Reside menu

@Bilal5008
Copy link

This issue is been resolved
boolean PermanentMenuKey = ViewConfiguration.get(getContext()).hasPermanentMenuKey();
if (!PermanentMenuKey) {//there's a navigation bar
bottomPadding = 0;
} else {
bottomPadding += getNavigationBarHeight();
}
Add this code ResideMenu Java class and you are good to go

@alex983k
Copy link

alex983k commented Apr 4, 2019

This issue is been resolved
boolean PermanentMenuKey = ViewConfiguration.get(getContext()).hasPermanentMenuKey();
if (!PermanentMenuKey) {//there's a navigation bar
bottomPadding = 0;
} else {
bottomPadding += getNavigationBarHeight();
}
Add this code ResideMenu Java class and you are good to go

Hi! Where should this code be added?

@alex983k
Copy link

alex983k commented Apr 4, 2019

This method did the trick for me. I tested on both devices with virtual navigation buttons and with phisical ones. I`ll post it here just in case someone needs it.

` @Override
    protected boolean fitSystemWindows(Rect insets) {
    Point appUsableSize = getAppUsableScreenSize(activity.getApplicationContext());
    Point realScreenSize = getRealScreenSize(activity.getApplicationContext());

    // This is added to fix soft navigationBar's overlapping to content above LOLLIPOP
    int bottomPadding = viewActivity.getPaddingBottom() + insets.bottom;
    
    //this line did the trick
    bottomPadding=realScreenSize.y-appUsableSize.y;

    this.setPadding(viewActivity.getPaddingLeft() + insets.left,
            viewActivity.getPaddingTop() + insets.top,
            viewActivity.getPaddingRight() + insets.right,
            bottomPadding);
    insets.left = insets.top = insets.right = insets.bottom = 0;
    return true;
}

public static Point getAppUsableScreenSize(Context context) {
    WindowManager windowManager = (WindowManager)   context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;
}

public static Point getRealScreenSize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= 17) {
        display.getRealSize(size);
    } else if (Build.VERSION.SDK_INT >= 14) {
        try {
            size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
            size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
        } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {}
    }

    return size;
}`

@akardas16
Copy link

This issue is been resolved
boolean PermanentMenuKey = ViewConfiguration.get(getContext()).hasPermanentMenuKey();
if (!PermanentMenuKey) {//there's a navigation bar
bottomPadding = 0;
} else {
bottomPadding += getNavigationBarHeight();
}
Add this code ResideMenu Java class and you are good to go

Hi! Where should this code be added?

Thanks man I replaced your code with ```
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME); if (!hasBackKey || !hasHomeKey) {//there's a navigation bar bottomPadding += getNavigationBarHeight(); } and problem dissapeared. you saved my hours.

@iam-asadullah
Copy link

old question but that's how I did it and it worked just like we all want.

resideMenu.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { mainLLL.setPadding(0,insets.getSystemWindowInsetTop(),0, insets.getSystemWindowInsetBottom()); return insets; } });

add this after initializing ResideMenu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants