Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove or hide header navigationView in android

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"
      />
like image 726
samira Avatar asked Oct 19 '22 21:10

samira


2 Answers

  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.

like image 164
samira Avatar answered Nov 03 '22 17:11

samira


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.

like image 23
Michał Janowicz Avatar answered Nov 03 '22 18:11

Michał Janowicz