主要功能:点击按钮弹出侧边栏;从屏幕边缘拖出侧边栏;当ViewPager的当前页为最左边的一页时,继续向右滑拖出侧边栏。
首先自定义一个布局,这个布局放侧边菜单栏。重写该布局的onMeasure和OnLayout来设置侧边菜单栏的宽度和位置。
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
View child = (View) getChildAt(0);
LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
ScreenTools screenTools = ScreenTools.instance(getContext());
layoutParams.width = mWidthOfSideMenu = (int) (screenTools.getScreenWidth() * SIDEMENUSCAL);
layoutParams.height = screenTools.getScreenHeight();
child.setLayoutParams(layoutParams);
mEdge = screenTools.dip2px(15);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean ch