Search code examples
androidandroid-layoutandroid-viewpagerandroid-custom-view

How can I change header layout every time swipe view pager(with tab layout)


I did design xml layout with drawerLayout + appBarLayout + collapsingLayout + header custom layout(imageView, textView and so on) + toolbar + tabLayout + viewPager by using Material Design.

But, I just want header custom layout to be changed dynamically every time view page(ex: fragment) is swiped and changed.

How can I do? I think that it makes sense to assign other header after inflating (other header)view to variable of header dynamically every time page swiped.

Thank you if you explain to me solution with example.


Solution

  • Try to find view pager change listener and define your customised header view code inside the change listener.