繁体   English   中英

在导航抽屉菜单的末尾设置特定的组项

[英]Set a particular group item at end in Navigation Drawer menu

好的, Google Keeps-Notes and Lists App 有一个这样的导航抽屉, Google Keeps-Notes and Lists App Navigation Drawer(Original)

  • 我想做与我在这张图片中提到的完全相同的事情。 我想要这个“编辑”

  • 我想要导航抽屉右侧的EDIT (TextView)。 我做到了这一点,我的导航抽屉

     <group> <item android:title="LABALS" android:actionLayout="@layout/main_nav_drawer_edit"> <menu> <item android:id="@+id/navigation_drawer_lable" android:title="Label 1" /> <item android:id="@+id/navigation_drawer_create_new_label" android:title="Create new label" /> </menu> </item>

我应该怎么做才能做到这一点,有可能吗?

创建一个自定义View并应用于您的<item>app:actionLayout属性。

<item
    android:id="@+id/grp_labeled"
    android:title="LABALS"
    app:actionLayout="@layout/main_nav_drawer_edit">
    <menu>
        <item
            android:id="@+id/navigation_drawer_lable"
            android:title="Label 1" />

        <item
            android:id="@+id/navigation_drawer_create_new_label"
            android:title="Create new label" />
    </menu>
</item>

布局:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="EDIT"
    android:textSize="18sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

像这样?

暂无
暂无

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

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