I
I
Ivan Nedzvetsky2014-07-16 19:40:52
Android
Ivan Nedzvetsky, 2014-07-16 19:40:52

How to open the Navigation Drawer with a swipe from the middle of the screen?

I use the standard Navigation Drawer in the android application.
Does it have the ability to open with a swipe from the middle of the screen and not from the edge.
For example, how the VKontakte application is made.
Figure for clarity:
4e6b158564394b26a1dd3235b26f0974.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
anyd3v, 2014-07-16
@anyd3v

In VK, you could do this when they did not use the Navigation Drawer, but used a self-made slide panel. As far as I know, there is no such functionality in the Navigation Drawer itself. From experience I can say that this is not worth doing and in the future you will only rake.
But if you really want to, then
1. Do gesture detection and finger movement on the content (onTouch and SimpleGustureListener)
2. use self-made solutions like https://github.com/jfeinstein10/SlidingMenu

M
Marat S, 2014-07-18
@aratj

yes, the distance is strictly prescribed in the classes themselves.
you can, in theory, do it through reflections,
SO for
example, such a solution gives

DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Field mDragger = mDrawerLayout.getClass().getDeclaredField(
        "mLeftDragger");//mRightDragger for right obviously
mDragger.setAccessible(true);
ViewDragHelper draggerObj = (ViewDragHelper) mDragger
        .get(mDrawerLayout);

Field mEdgeSize = draggerObj.getClass().getDeclaredField(
        "mEdgeSize");
mEdgeSize.setAccessible(true);
int edge = mEdgeSize.getInt(draggerObj);

mEdgeSize.setInt(draggerObj, edge * 5); // вот тут меняем размер.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question