5

i am using design 23.1.1 in my project. i want drawer without header. just menu items are enough. i dont add any header view(programmatically or in XML). but in drawer i have empty header. please help me how to remove this empty header.

 <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="right" app:menu="@menu/drawer" /> 

4 Answers 4

6
 View headerView= LayoutInflater.from(this).inflate(R.layout.drawer_header, null); navigationView.addHeaderView(headerView); navigationView.getHeaderView(0).setVisibility(View.GONE); 

i use dummy layout. and solved my problem but i think it is ridiculous.

Sign up to request clarification or add additional context in comments.

1 Comment

What is the import you are using for NavigationView? I am using navigationView from design support library and is unable to find the method "navigationView.getHeaderView()".
2

If You want to remove header:

navigationView.removeHeaderView(navigationView.getHeaderView(0)); 

Of cource if You have more haeders You have to do this in some loop to remove them all. 0 is index of the first one.

Comments

0

try to add this to your style file <item name="android:windowFullscreen">true</item>

and remove app:headerLayout from navigationView xml.

and add this to your navigationView xml :

android:layout_marginTop ="@dimen/abc_action_bar_default_height_material" 

it worked perfect for me.

Comments

-3

To remove it permanently:

The Layout that contains the NavigationView widget is like this:

<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"/> 

Just remove the app:headerLayout line from it:

 app:headerLayout="@layout/nav_header_main" 

1 Comment

Headers comes again after removing headerLayout from navigationView..How to fix it?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.