android边栏菜单<上下左右四个方向>
关键性代码:
?
?a.初始化时位置处理
?
/** * 当Menu菜单在左边时 * @param event */protected void menuLeftMoveEvent(MotionEvent event) {float distance = event.getX() - MOTIONEVENT_X;//向右滑动,打开菜单栏if(distance > 0) {if(distance + mMovePosition >= 0) {ISMENU_OPEN = true;mMovePosition = 0;smoothScrollTo(M_SLIDER_MAX_OPEN, 0);return ;}else {mMovePosition += distance;}}else if(distance < 0) {if(distance + mMovePosition <= -MENU_WIDTH) {ISMENU_OPEN = false;mMovePosition = -MENU_WIDTH;smoothScrollTo(M_SLIDER_MAX_CLOSE, 0);return ;}else {mMovePosition += distance;}}smoothScrollBy((int) - distance, 0);MOTIONEVENT_X = event.getX();}
?其它一些代码都做过相应的注释 整个工程在附件中.
?