Use XTablayout to implement horizontal sliding menu, xtablayout horizontal
Implementation result: the number of tablayout instances is 2, and the width of the navigation bar can be set (tablayout does not have this attribute. XTablayout is used here)
Import dependency:
Compile 'com. androidkun: XTabLayout: 1.1.3'
Layout:
Meaning of the attribute:
Navigation bar color
App: xTabIndicatorColor = "#03A9F4"
Height of the navigation bar:
App: xTabIndicatorHeight = "5dp"
Width of the navigation bar:
App: xTabIndicatorWidth = "100dp"
Color of the selected text:
App: xTabSelectedTextColor = "#03A9F4"
Minimum width:
App: xTabMinWidth = "240dp"
Maximum width:
App: xTabMaxWidth = "480dp"
After finding the id in the Code, set the interaction with viewpager.
// Set the interaction between viewpager and Xtablayout and xTablayout. setupWithViewPager (viewPager );