在抽屉菜单的页脚中添加按钮

时间:2016-04-21 09:58:40

标签: android xml navigation-drawer

我想在抽屉菜单下添加这些按钮

drawerMenu

这些是我的xml文件:

(布局/ activity_main)

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

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

(菜单/ activity_main_drawer)

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group
        android:checkableBehavior="single">
        <item
            android:id="@+id/nav_log"
            android:title="Log-in" />
        <item
            android:id="@+id/nav_preferiti"
            android:title="Preferiti" />
        <item
            android:id="@+id/nav_maps"
            android:title="Mappa" />
        <item
            android:id="@+id/nav_terms"
            android:title="Termini e condizioni" />
        <item
            android:id="@+id/nav_who"
            android:title="Chi Siamo" />
        <item
            android:id="@+id/nav_settings"
            android:title="Impostazioni" />
        <item
            android:id="@+id/nav_tutorial"
            android:title="Tutorial" />
    </group>

</menu>

我尝试使用重力底部(或结束)的线性布局,但它仍保留在顶部

2 个答案:

答案 0 :(得分:3)

尝试在NavigationView内添加其他观看内容,例如:

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true">

            <!--Here is a container at the bottom of navigation drawer. Place your images here-->

        </LinearLayout>

    </RelativeLayout>

</android.support.design.widget.NavigationView>

答案 1 :(得分:0)

试试这个!

menu / activity_main_drawer

在论坛

之后添加以下内容
<item android:title="">
    <menu>
        <item
            android:id="@+id/nav_about_us"
            android:title="Follow us:"
            app:actionLayout="@layout/share"
            app:showAsAction="ifRoom"/>
    </menu>
</item>

your_custom_layout.xml 可能类似

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:orientation="vertical"
    android:background="@color/colorPrimaryDark">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center">

       <ImageButton
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/right_arrow"/>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/right_arrow"/>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/right_arrow"/>

    </LinearLayout>

</LinearLayout>