SpecialCyCi / AndroidResideMenu

The idea of ResideMenu is from Dribbble 1 and 2. It has come true and run in iOS devices. iOS ResideMenu This project is the RefsideMenu Android version. The visual effect is partly referred to iOS version of ResideMenu. And thanks to the authors for the above idea and contribution.
MIT License
2.85k stars 1.1k forks source link

View being hidden behind Software buttons / Navigation Bar of Phone #116

Open ECD00UFA opened 7 years ago

ECD00UFA commented 7 years ago

The problem i have been facing with phones having software buttons :

![Uploading device-2016-12-09-154816.png…]()

Please refer some solution..

mostafahashim commented 7 years ago

any solution please?

niteshsirohi1 commented 7 years ago

Make these changes in ResideMenu class

  @Override
   protected boolean fitSystemWindows(Rect insets) {
// Applies the content insets to the view's padding, consuming that
// content (modifying the insets to be 0),
// and returning true. This behavior is off by default and can be
// enabled through setFitsSystemWindows(boolean)
// in api14+ devices.
Point appUsableSize = getAppUsableScreenSize(mContext);
Point realScreenSize = getRealScreenSize(mContext);

boolean hasBackKey=false;
// navigation bar at the bottom
if (appUsableSize.y < realScreenSize.y) {
    hasBackKey=true;
}
    // This is added to fix soft navigationBar's overlapping to content above LOLLIPOP
     int bottomPadding = viewActivity.getPaddingBottom() + insets.bottom;

if (hasBackKey ) {//there's a navigation bar
    bottomPadding += getNavigationBarHeight();
}

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

And these methods

     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;
}
AliYusuf95 commented 7 years ago

@niteshsirohi1 Thank you, you saved my day.

mani516 commented 5 years ago

You can refer my solution here. It works with gesture navigations also https://github.com/SpecialCyCi/AndroidResideMenu/issues/121#issuecomment-460137552