Android Sliding TabLayout Example


An Android TabLayout Lib has 3 kinds of TabLayout at present.
  • SlidingTabLayout: deeply modified from PagerSlidingTabStrip.
    • new added attribute
    • new added kinds of indicators
    • new added unread msg tip
    • new added method for convenience
        /** no need to set titles in adapter */
        public void setViewPager(ViewPager vp, String[] titles)
        /** no need to initialize even adapter */
        public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, ArrayList<Fragment> fragments) 
  • CommonTabLayout:unlike SlidingTabLayout's dependence on ViewPager,it is a tabLayout without dependence on ViewPager and can be used freely with other widgets together.
    • support kinds of indicators and indicator animation
    • support unread msg tip
    • support icon and icon gravity.
    • new added method for convenience
        /** support switch fragments itself */
        public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentManager fm, int containerViewId, ArrayList<Fragment> fragments)
  • SegmentTabLayout



    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.flyco.roundview:FlycoRoundView_Lib:[email protected]'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:[email protected]'

After v2.0.0
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:[email protected]'

After v2.0.2(support 3.0+)
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:[email protected]'


tl_indicator_colorcolorset indicator color
tl_indicator_heightdimensionset indicator height
tl_indicator_widthdimensionset indicator width
tl_indicator_margin_leftdimensionset indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_topdimensionset indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_rightdimensionset indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_bottomdimensionset indicator margin,invalid when indicator width is greater than 0.
tl_indicator_corner_radiusdimensionset indicator corner radius
tl_indicator_gravityenumset indicator gravity TOP or BOTTOM.
tl_indicator_styleenumset indicator style NORMAL or TRIANGLE or BLOCK
tl_underline_colorcolorset underline color
tl_underline_heightdimensionset underline height
tl_underline_gravityenumset underline gravity TOP or BOTTOM
tl_divider_colorcolorset divider color
tl_divider_widthdimensionset divider width
tl_divider_paddingdimensionset divider paddingTop and paddingBottom
tl_tab_paddingdimensionset tab paddingLeft and paddingRight
tl_tab_space_equalbooleanset tab space equal
tl_tab_widthdimensionset tab width
tl_textsizedimensionset text size
tl_textSelectColorcolorset text select color
tl_textUnselectColorcolorset text unselect color
tl_textBoldbooleanset text is bold
tl_iconWidthdimensionset icon width(only for CommonTabLayout)
tl_iconHeightdimensionset icon height(only for CommonTabLayout)
tl_iconVisiblebooleanset icon is visible(only for CommonTabLayout)
tl_iconGravityenumset icon gravity LEFT or TOP or RIGHT or BOTTOM(only for CommonTabLayout)
tl_iconMargindimensionset icon margin with text(only for CommonTabLayout)
tl_indicator_anim_enablebooleanset indicator support animation(only for CommonTabLayout)
tl_indicator_anim_durationintegerset indicator animation duration(only for CommonTabLayout)
tl_indicator_bounce_enablebooleanset indicator aniamtion with bounce effect(only for CommonTabLayout)
tl_indicator_width_equal_titlebooleanset indicator width same as text(only for SlidingTabLayout)
Download From GitHub
Download Full Project Code From GitHub
android-tabs-examples 6560299973791944324
Home item