Navigation drawer starts from right side

前端 未结 3 1093
猫巷女王i
猫巷女王i 2021-01-29 01:47

How can i make the navigation drawer open from the right to the left?

Main.xml



        
相关标签:
3条回答
  • 2021-01-29 02:17

    it does change , only two things to do ,

    After addig a new activity to your android app from android studio->file->new->activity ->Navigation Draw....

    you have to change android:layout_gravity="right" in main layout's android.support.design.widget.NavigationView and drawer.closeDrawer(GravityCompat.END); in your OnNavigationItemSelected() function in main activity .

    0 讨论(0)
  • 2021-01-29 02:32

    In your main.xml there is the android.support.design.widget.NavigationView which has the following attribute: android:layout_gravity="end". You have to set it to right, so it will be like this: android:layout_gravity="right". The rest is done by the design support lib.

    Note that the Android Studio will show a warning that you should use end instead of right in order to ensure correct behavior in right-to-left languages. You can ignore this message.

    0 讨论(0)
  • 2021-01-29 02:33

    Try setting android:layout_gravity="end" instead of android:layout_gravity="start"

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />
    
    0 讨论(0)
提交回复
热议问题