【问题标题】:Is there any way to set the navigation drawer as visible always有没有办法将导航抽屉设置为始终可见
【发布时间】:2014-07-13 20:41:48
【问题描述】:

有没有办法将抽屉式导航设置为始终可见?

让用户知道右边/左边有东西。

就像你在环聊应用中看到的一样。

我知道环聊使用 SlidePaneLayout,但是有人知道如何使用 Navigation Drawer 来实现这一点吗?

【问题讨论】:

  • 如果您的抽屉式导航始终可见,那么屏幕上就没有空间了,我想唯一可行的方法是在平板电脑上使用 2 个片段,1 个用于抽屉,然后1 为内容。这里有一个很好的参考stackoverflow.com/questions/17133541/…
  • NavigationDrawer 并不是为了这个目的。要么使用 SlidingPaneLayout,要么创建你自己的布局,拥有你想要的行为。
  • 我希望导航抽屉的一小部分可见,例如手柄。让用户注意到它。
  • @Karakuri,我试过 SlidingPaneLayout ,但在关闭状态下它覆盖了整个窗口。我需要一点背景才能看到。
  • 同样,您可以使用您想要的行为创建自己的布局。或许SlidingPaneLayout的源码能给你一些思路:android.googlesource.com/platform/frameworks/support/+/refs/…

标签: android navigation-drawer


【解决方案1】:

明白了!!.. 最简单。没有库,没有复杂的代码。使用 SimplePaneLayout

只需将 android:layout_marginLeft 设置为合适的值。 :) 太棒了:)

<android.support.v4.widget.SlidingPaneLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/slidingpanelayout">

        <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="#CCC"
                  android:orientation="horizontal"
                  android:id="@+id/fragment_firstpane"/>

        <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="#000"
                  android:orientation="horizontal"
                  android:layout_marginLeft="40dp"
                  android:id="@+id/fragment_secondpane"/>

    </android.support.v4.widget.SlidingPaneLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    • 2014-05-03
    相关资源
    最近更新 更多