Android侧面类别选择菜单:Side Menu

jopen 10年前

轻松为你的Android项目添加侧面类别选择菜单。

<android.support.v4.widget.DrawerLayout      xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/drawer_layout"      android:layout_width="match_parent"      android:layout_height="match_parent">        <io.codetail.widget.RevealFrameLayout          android:id="@+id/conteiner_frame"          xmlns:android="http://schemas.android.com/apk/res/android"          android:layout_width="match_parent"          android:layout_height="match_parent">          <LinearLayout              android:id="@+id/content_overlay"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:orientation="vertical"/>          <LinearLayout              android:id="@+id/content_frame"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:orientation="vertical"/>            <android.support.v7.widget.Toolbar              android:id="@+id/toolbar"              android:layout_height="wrap_content"              android:layout_width="match_parent"              android:minHeight="?attr/actionBarSize"              android:background="?attr/colorPrimary"/>        </io.codetail.widget.RevealFrameLayout>        <ScrollView          android:id="@+id/scrollView"          android:scrollbarThumbVertical="@android:color/transparent"          android:layout_width="80dp"          android:layout_height="match_parent"          android:layout_gravity="start|bottom">            <LinearLayout              android:id="@+id/left_drawer"              android:orientation="vertical"              android:layout_width="80dp"              android:layout_height="wrap_content"              android:divider="@android:color/transparent"              android:dividerHeight="0dp"              android:background="@android:color/transparent">              <!-- Layout of Drawer -->          </LinearLayout>      </ScrollView>  </android.support.v4.widget.DrawerLayout>

   ViewAnimator viewAnimator = new ViewAnimator<>(ActionBarActivity.this,                                      new ArrayList<Resourceble>(),                                      (LinearLayout) findViewById(R.id.left_drawer),                                       contentFragment, drawerLayout);      //to open menu you have to override ActionBarDrawerToggle method               @Override              public void onDrawerSlide(View drawerView, float slideOffset) {                  super.onDrawerSlide(drawerView, slideOffset);                  if (slideOffset > 0.6 && viewAnimator.getLinearLayout().getChildCount() == 0)                      viewAnimator.showMenuContent();              }              public void onDrawerClosed(View view) {                  super.onDrawerClosed(view);                  viewAnimator.getLinearLayout().removeAllViews();                  viewAnimator.getLinearLayout().invalidate();              }

项目主页:http://www.open-open.com/lib/view/home/1421571203468