Android - How to implement a NavigationDrawer that is partially visible at all times?

喜夏-厌秋 提交于 2019-11-29 07:33:06

I came across this open source library, https://github.com/StevenRudenko/ActionsContentView. I haven't personally used it so can't say it will fit in your exact use case of having a drawer at right but it does has the drawer on the left. Even then you could start from there and should be able to build upon it to fit your use case.

thanks for all the answers. Here is what I did to make it work:

I used overlapping fragments and animation like suggested. While onCreate I calculated manually the width for the map (screensize - the drawer size while collapsed) so that it doesn't stretch strangely while modifying the drawer size. I set the drawer inside a fragment and the fragment visible at all times. After that I implemented OnGestureListener and made a GestureDetector to my activity, and started listening to touch events from the Drawer:

drawer.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View view, MotionEvent e) {
            gestureDetector.onTouchEvent(e);
            return false;
        }
    });

and then onFling-method

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    if(velocityX < -250) {
         //animation for increasing the list width from 80 to 240
    } else if (velocityY > 250 ) {
         //animation for decreasing the list width from 240 to 80
    }
    return true;
    }

I would recommend that you use two overlapping fragments for this scenario. You can look at http://developer.android.com/guide/practices/tablets-and-handsets.html and http://developer.android.com/guide/components/fragments.html for guides.

If you have any more specific queries let me know.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!