Is there any way to control views inside NavigationView header?

后端 未结 4 2312
我在风中等你
我在风中等你 2020-12-03 03:07

As the title says, I want to know if there is any way to control views inside the NavigationView header? (Except for adding or removing header.)

For exa

4条回答
  •  情话喂你
    2020-12-03 03:26

    Since i can not accept a comment as an answer. So, i repost Moinkhan' answer here:

    first create header XML like lay_header.xml

    
    

    on your java file inflate this above header in a TextView. like

    TextView headerView = (TextView) LayoutInflater.from(this).inflate(R.layout.lay_header, null);
    headerView.setText("Your_thoght");
    

    Now add it as a HeaderView

    navView = (NavigationView) findViewById(R.id.navView);
    navView.addHeaderView(headerView);
    

    Thats it...

    You can also check it out at: Customising NavigationView - Adding dynamic headerView, Android Support Design Library

    Many thanks! And again, we need a function that allow user to accept a comment as answer!

提交回复
热议问题