如何在Android中向侧导航栏添加图像和边框

如何在Android中向侧导航栏添加图像和边框,android,xml,android-layout,Android,Xml,Android Layout,我想将边框和图像添加到侧面NavigationDrawer,如何操作。我试过了,但找不到合适的教程。我的XML文件是我们在Android中选择导航抽屉活动时得到的,没有任何变化。 我在下面粗略地画出了我想要的样子。任何帮助都将不胜感激,谢谢。另外,请忽略标题的橙色背景。我不想要它,我只想在头部和身体上都有Gru图像 我想在身体上的形象,以及导航抽屉的标题。一张图片覆盖身体和头部 虽然这看起来很难,但通过为标题和导航设计不同的背景,您可以轻松实现这一点。尝试将图像置于导航栏背景中,并使标题背景透明

我想将边框和图像添加到侧面
NavigationDrawer
,如何操作。我试过了,但找不到合适的教程。我的XML文件是我们在Android中选择导航抽屉活动时得到的,没有任何变化。 我在下面粗略地画出了我想要的样子。任何帮助都将不胜感激,谢谢。另外,请忽略标题的橙色背景。我不想要它,我只想在头部和身体上都有Gru图像

我想在身体上的形象,以及导航抽屉的标题。一张图片覆盖身体和头部


虽然这看起来很难,但通过为标题和导航设计不同的背景,您可以轻松实现这一点。尝试将图像置于导航栏背景中,并使标题背景透明,以便显示相同的图像。此外,您还应该使用笔划作为蓝线边框

让我给你看一个基本的例子

导航头

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <stroke android:color="@color/blueshade"
        android:width="4dp"
        />
    <corners android:topRightRadius="35dp"
        />
    <solid android:color="@android:color/transparent"/>


</shape>

导航栏

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">


    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
            <stroke android:color="@color/blueshade"
                android:width="4dp"
                />

            <corners android:topRightRadius="35dp"
                android:bottomRightRadius="35dp"/>
            <solid android:color="@android:color/white"/>

        </shape>
    </item>

    <item android:right="20dp" android:left="5dp" android:top="5dp" android:bottom="5dp" >
        <bitmap android:src="@drawable/gru"
            android:gravity="fill"
            android:alpha="105"
            />
    </item>
</layer-list>


现在,您可以将导航顶部设置为
nav\u header\u main
布局的背景,将导航栏设置为
NavigationView
活动\u main
布局的背景,这是否回答了您的问题?不,我希望图像完全放在导航抽屉上,而不仅仅是头部。谢谢谢谢你Shubham,我知道这种方法是可行的。但由于在得到解决方案时反应迟钝,我们实际上转移到了不同的布局。还是非常感谢你帮我学习