0

I want to add border and image to side NavigationDrawer , how do I do it. I tried but I cannot find a proper tutorial for it. My XML files are how you get when we chose a navigation drawer activity in Android, nothing changed in it. I have drawn it below roughly about how I want it to be. Any help would be appreciated thank you. Also please ignore the orange background of header. I do not want it, I would just like the Gru image on both head and body

I want the image to be there on the body as well as header of the navigation drawer. One single image covering the body as well as header.

Rough representation

FrootyDoot
  • 23
  • 5
  • Does this answer your question? [Android: Navigation Drawer Header Image](https://stackoverflow.com/questions/41335614/android-navigation-drawer-header-image) – Nicolas Aug 23 '20 at 01:13
  • No , i want the image to be fully on the navigation drawer and not just the head. Thank you – FrootyDoot Aug 23 '20 at 08:09

1 Answers1

1

While this looks like tough you can achieve this easily by designing backgrounds for the header and nav differently. Try putting the image in navbar background and making the header background transparent so that the same image is shown. Also you should use stroke for the blue lined border.

Let me show you a basic example for it

For nav-header

<?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>

For navbar

<?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>

Now you can set the nav-top as background for nav_header_main layout and the navbar as background for NavigationView in activity_main layout

Shubham Rohila
  • 366
  • 2
  • 12
  • Thank You Shubham, I saw that this way can work. But due to late response in getting the solution we actually moved to a different layout. Still thank you so much for helping me learn – FrootyDoot Aug 30 '20 at 13:25