【问题标题】:How can I open navigation drawer from right side to left [duplicate]如何从右侧到左侧打开导航抽屉[重复]
【发布时间】:2013-07-25 07:50:33
【问题描述】:
  1. 我想像图片一样从右到左打开
  2. 这是我的代码,我可以在哪里更改从右到左打开。

<FrameLayout
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</FrameLayout>

<ListView
    android:id="@+id/drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />

【问题讨论】:

    标签: android


    【解决方案1】:

    在您的主布局中,将您的 ListView 重力设置为结束: 采用 android:layout_gravity="end"

    【讨论】:

      【解决方案2】:

      布局:

          <?xml version="1.0" encoding="utf-8"?>
      <android.support.v4.widget.DrawerLayout
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/activity_messages"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent">
                  <!-- The main content view -->
                  <FrameLayout
                      android:id="@+id/activity_messages_content"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" />
                  <!-- The navigation drawer -->
                  <FrameLayout
                      android:id="@+id/activity_messages_drawer"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_gravity="end"
                      android:choiceMode="singleChoice"
                      android:divider="@android:color/transparent"
                      android:dividerHeight="0dp"
                      android:background="@drawable/bg_background_gradient"/>
              </android.support.v4.widget.DrawerLayout>
      

      活动中:

      mLayout = (DrawerLayout)findViewById(R.id.activity_messages);
          mLayout.openDrawer(Gravity.RIGHT);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多