【问题标题】:How to slide the Activity along with the NavigationDrawer from right side?如何从右侧滑动 Activity 和 Navigation Drawer?
【发布时间】:2015-05-29 13:38:01
【问题描述】:

我想在我的应用程序中实现与 facebook 应用程序类似的滑动 NavigationDrawer,我对如何执行此操作进行了一些研究,并根据此答案从这个问题 How to slide the ActionBar along with the NavigationDrawer 中找到了答案我实现了菜单获取的 NavigationDrawer从左侧滑动,但我希望它从右侧滑动如何实现?

等待答案!

提前致谢。

【问题讨论】:

    标签: 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
    • 我已经根据你的需要更新了我的答案,请检查一下
    • 不,这对我没有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多