Open stoichoandreev opened 8 years ago
@stoichoandreev any update?
Hey @dimohamdy, I am really sorry but my comment was a long time ago, so I don't even remember the project where I used this Menu. I remember some context of this idea, but not much. If you need some help please let me know so I can try to find the source code (if I can :) ). As long as I remember the idea was to make the Menu visible only if you drag really close to the screen edge
@stoichoandreev please told me how to fix this issue
Hi there I am using your menu, because it is awesome, and btw well done, and thanks to sharing it :). I would like to help you a little bit and make this menu one step better. My idea is: When you check for ignoringviews range , you can remove some part of the screen edges because usually the menu should work like drawer menu (when you swipe exactly from the screen edges menu should open, does not matter is this touch event into ignored view range). I have made a little changes in your code: private boolean isInIgnoredView(MotionEvent ev) { Rect rect = new Rect(); //to open the menu when user touch for the first time in screen edges we need to remove from the X coord. The desired X touch area final boolean isTouchFromTheLeftScreenSide = ev.getX() < getWidth()/2 ? true : false; final float xTouchPosition = isTouchFromTheLeftScreenSide ? (ev.getX() - openMenuScreenEdgeRange) : (ev.getX() + openMenuScreenEdgeRange); for (View v : ignoredViews) { v.getGlobalVisibleRect(rect); if (rect.contains((int) xTouchPosition, (int) ev.getY())) return true; } return false; }
so variable openMenuScreenEdgeRange is float and it is global for the menu object, you can set it using some public method if you want different edge of the screen to be ignored when you calculating isInIgnoredView(MotionEvent ev). And one more small thing when you setting your openMenuScreenEdgeRange you have to add (for example 2) some small int value, because when the touch event is in your edge area , for final float xTouchPosition you will receive 0 for left and screenWidth for right touches. I hope it will be useful for you, like your code is useful for me.