【问题标题】:How to slide the Activity along with the NavigationDrawer from right side?如何从右侧滑动 Activity 和 Navigation Drawer?
【发布时间】:2015-05-29 13:38:01
【问题描述】:
【问题讨论】:
标签:
android
facebook
navigation-drawer
【解决方案1】:
就像左抽屉一样简单
<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">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="400dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
<ListView
android:id="@+id/right_drawer"
android:layout_width="400dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
并将其初始化为与左侧抽屉相同。
参考这个link
然后实施
onDrawerSlide(View drawerView, float slideOffset).
并添加行mDrawerLayout.findViewById(R.id.main_contain_id).setTranslationX(drawerView.getWidth() * slideOffset);
【讨论】:
-
感谢您的回复,但问题是我想要类似于 facebook 应用程序的 NavigationDrawer,即完整的 ActionBar 也应该与 NavigationDrawer 一起移动,默认情况下 android DrawerLayout 不会提供此行为。检查这张图片我需要这种行为link
-
-