繁体   English   中英

Android导航抽屉:将项目或组停靠到底部

[英]Android navigation drawer: Dock item or group to bottom

我想知道如何像在Google Inbox应用中那样将项目或组停靠在导航抽屉的底部:

在此处输入图片说明

在我的NavDrawer xml中找不到相应的选项:

<item android:title="Generalt">
    <menu>
        <item
            android:id="@+id/nav_send"
            android:icon="@android:drawable/ic_lock_power_off"
            android:title="Log af" />
    </menu>
</item>

在Navigation Drawer fragment ,需要放置一个scrollview然后在其中放入LinearLayout ,它将具有可滚动的视图,而在scrollview之外,您必须使用layout:gravity:bottom制作另一个LinearLayout ,因为它位于scrollview之外。将不会滚动并保持在底部:)

如#deep513所述,您必须修改导航抽屉片段。 这是一个示例,在这种情况下,我使用了列表视图而不是滚动视图,但这取决于您的需求。

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            tools:context=".NavigationDrawerFragment">


    <ListView
           android:layout_height="0dp"
           android:layout_weight="1"
           android:layout_width="match_parent"
           android:divider="@android:color/transparent"
           android:dividerHeight="0dp"
           android:background="#cccc"
           android:choiceMode="singleChoice"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Help"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Settings"/>
    </LinearLayout>

</LinearLayout>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM