在导航抽屉底部添加图片

3

我想问关于Android导航抽屉的问题。这是我想要实现的屏幕截图。

enter image description here

我正在使用来自 Android Studio 的默认导航抽屉。我的问题非常基础,但我是 Android Studio 的新手。提前感谢大家。这是 activity_main 布局。

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"
    android:background="@color/background"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer"/>

`

1个回答

15

试试这个

<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"
        android:background="@color/background"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:clickable="true"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/ic_launcher_background" />

        </LinearLayout>


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

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

1
Rathor,如果我的菜单项太多需要滚动才能到达NavigationView的底部,会发生什么?如果您知道,请帮我解决这个问题。 - Aminul Haque Aome
@Omi,你可以像这样使用自定义NavigationView https://dev59.com/vVUL5IYBdhLWcg3wf4J0#51094894 顺便问一下,你能展示一些图片来说明你的实际需求吗? - AskNilesh
@Rathod,这是示例图片的链接,请查看。https://imgur.com/PuAZXBo。我想在我的导航抽屉底部放置那4个社交图片。 - Aminul Haque Aome

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接