An Android TabLayout Lib

Overview

FlycoTabLayout

Android Arsenal

中文版

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

Demo

Change Log

v2.0.0(2016-03-01)

  • remove the dependence of FlycoRoundView
  • new added method getIconView and getTitleView

v2.0.2(2016-04-23)

  • remove the dependence of NineOldAnimation(only support 3.0+)

Gradle

dependencies{
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.5.0@aar'
}

After v2.0.0
dependencies{
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.0@aar'
}

After v2.0.2(support 3.0+)
dependencies{
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
}

Attributes

name format description
tl_indicator_color color set indicator color
tl_indicator_height dimension set indicator height
tl_indicator_width dimension set indicator width
tl_indicator_margin_left dimension set indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_top dimension set indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_right dimension set indicator margin,invalid when indicator width is greater than 0.
tl_indicator_margin_bottom dimension set indicator margin,invalid when indicator width is greater than 0.
tl_indicator_corner_radius dimension set indicator corner radius
tl_indicator_gravity enum set indicator gravity TOP or BOTTOM.
tl_indicator_style enum set indicator style NORMAL or TRIANGLE or BLOCK
tl_underline_color color set underline color
tl_underline_height dimension set underline height
tl_underline_gravity enum set underline gravity TOP or BOTTOM
tl_divider_color color set divider color
tl_divider_width dimension set divider width
tl_divider_padding dimension set divider paddingTop and paddingBottom
tl_tab_padding dimension set tab paddingLeft and paddingRight
tl_tab_space_equal boolean set tab space equal
tl_tab_width dimension set tab width
tl_textsize dimension set text size
tl_textSelectColor color set text select color
tl_textUnselectColor color set text unselect color
tl_textBold boolean set text is bold
tl_iconWidth dimension set icon width(only for CommonTabLayout)
tl_iconHeight dimension set icon height(only for CommonTabLayout)
tl_iconVisible boolean set icon is visible(only for CommonTabLayout)
tl_iconGravity enum set icon gravity LEFT or TOP or RIGHT or BOTTOM(only for CommonTabLayout)
tl_iconMargin dimension set icon margin with text(only for CommonTabLayout)
tl_indicator_anim_enable boolean set indicator support animation(only for CommonTabLayout)
tl_indicator_anim_duration integer set indicator animation duration(only for CommonTabLayout)
tl_indicator_bounce_enable boolean set indicator aniamtion with bounce effect(only for CommonTabLayout)
tl_indicator_width_equal_title boolean set indicator width same as text(only for SlidingTabLayout)

Dependence

Thanks

Comments
  • SlidingTabLayout之动态添加删除tab

    SlidingTabLayout之动态添加删除tab

    动态添加tab时,并且滑动到新添加的tab页demo会报错

    Process: com.flyco.tablayoutsamples, PID: 5173
     java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getWidth()' on a null object reference
    at com.flyco.tablayout.SlidingTabLayout.scrollToCurrentTab(SlidingTabLayout.java:343)
    at com.flyco.tablayout.SlidingTabLayout.onPageScrolled(SlidingTabLayout.java:324)
    
    opened by guominfang 11
  • 设置了tablayout.setCurrentTab(currentIndex, false);但是不生效

    设置了tablayout.setCurrentTab(currentIndex, false);但是不生效

        tablayout.setTabSpaceEqual(true);
        searchViewpaer.setOffscreenPageLimit(mFragmentList.size());
        searchViewpaer.setAdapter(new SearchPagerAdapter(getSupportFragmentManager()));
        tablayout.setViewPager(searchViewpaer, mTabs);
        tablayout.setCurrentTab(currentIndex, false);
    

    版本:2.0.8; 设置了tablayout.setCurrentTab(currentIndex, false);但还是会划过中间界面,是我用的不对么?

    opened by weinierfei 7
  • 不支持ButterKnife吗?例子能不能简单点啊

    不支持ButterKnife吗?例子能不能简单点啊

    不支持ButterKnife吗?必须用(compile 'com.android.support:support-v4:23.1.1')这个库?例子能不能简单一点啊,插一堆很难理清楚头绪。有点注释就更好了。 还有就是,你这用起来设置属性很复杂,能否拆成几种模式,或者是单独的空间,或自定义布局来使用?

    opened by songj056 7
  • Problem with Indicator

    Problem with Indicator

    hi. I have a confusing problem when I use block indicator somthing like this:

    code:

    tl:tl_indicator_corner_radius="0dp" tl:tl_indicator_margin_bottom="0dp" tl:tl_indicator_margin_left="0dp" tl:tl_indicator_margin_right="0dp" tl:tl_indicator_margin_top="0dp"

    tl:tl_indicator_style="BLOCK"

    when I use this code in most android devices the indicator do not show. (in emulator works perfectly)

    plz help me!

    thank you so much...

    opened by hamidraasti 6
  • SlidingTabLayout滑动必须依赖于ViewPager的滑动吗?可否只滑动Tab中的Indicator?

    SlidingTabLayout滑动必须依赖于ViewPager的滑动吗?可否只滑动Tab中的Indicator?

    大神好! 需求背景:有很多个Tab要展示,超出屏幕展示范围,发现只有SlidingTabLayout支持这种,所以选择SlidingTabLayout。 问题: SlidingTabLayout依赖于ViewPager,但我们的需求是切换时不展示动画,所以ViewPager切换时调viewPager.setCurrentItem(item, false)函数(第2个参数为false),发现这样调用之后,Indicator也没有了滑动效果,SlidingTabLayout滑动效果必须依赖于ViewPager的滑动吗?这种情况下,如何让Indicator具备滑动效果?

    opened by dinglin87 5
  • 指示器不显示

    指示器不显示

    显示

    image of myTest

    代码

    <com.flyco.tablayout.SlidingTabLayout
            android:id="@+id/stlIndicator"
            android:layout_width="match_parent"
            android:layout_height="54dp"
            app:tl_indicator_color="@color/carouse_orange"
            app:tl_indicator_gravity="BOTTOM"
            app:tl_indicator_height="2dp"
            app:tl_indicator_style="NORMAL"
            app:tl_tab_space_equal="true"
            app:tl_indicator_width_equal_title="true"
            app:tl_textSelectColor="@color/black_light"
            app:tl_textUnselectColor="@color/gray"
            app:tl_textsize="16sp"
            app:tl_underline_color="@color/carouse_yellow"
            app:tl_underline_gravity="BOTTOM"
            app:tl_underline_height="1dp"
     />
    
    opened by bocq 5
  • 使用SlidingTabLayout,新打开Activity然后关闭,刷新当前页面,title不会切回

    使用SlidingTabLayout,新打开Activity然后关闭,刷新当前页面,title不会切回

    出现异常流程: 在当前ActivityA中使用SlidingTabLayout——>切换到TAB2——>在当前ActivityA打开新的ActivityB——>关闭ActivityB——>刷新ActivityA——>这时TAB指示器和显示的都是是第一个,但是title确还是停留在第二个上面 表达能力不行,大概就是上面这样子

    opened by ghost 5
  • How to use in styles.xml?

    How to use in styles.xml?

        <style name="MyTab">
            <item name="android:background">@color/white</item>
            <item name="com.flyco.tablayout:tl_indicator_color">@color/primary</item>
        </style>
    

    or

    <resources xmlns:tl="http://schemas.android.com/apk/res-auto">
        <style name="MyTab">
            <item name="android:background">@color/white</item>
            <item name="tl:tl_indicator_color">@color/primary</item>
        </style>
    </resources>
    

    are all build failed and messages are "Error:(2682, 21) No resource found that matches the given name: attr 'com.flyco.tablayout:tl_indicator_color'." or "Error:(2682, 21) No resource found that matches the given name: attr 'tl:tl_indicator_color'."

        compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.0@aar'
    
    opened by Andecy 4
  • 适配 androidX

    适配 androidX

    • update gradle from 2.14.1 to 5.4.1
    • update android build tool gradle from 2.2.3 to 3.4.1
    • update compileSdkVersion to 28
    • replace android support library to androidX library
    opened by geek5nan 3
  • 已解决:SegmentTabLayout segmentTab = new SegmentTabLayout(this);  on a null object reference

    已解决:SegmentTabLayout segmentTab = new SegmentTabLayout(this); on a null object reference

    SegmentTabLayout segmentTab = new SegmentTabLayout(this);

    Attempt to invoke interface method 'java.lang.String android.util.AttributeSet.getAttributeValue(java.lang.String, java.lang.String)' on a null object reference

    原因是

    //get layout_height String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

    想问问作者我该如何用代码new出来

    opened by beilo 3
  • 和Navigation搭配 rootFragment内放改控件,会导致内容不显示的问题

    和Navigation搭配 rootFragment内放改控件,会导致内容不显示的问题

    这是绑定Navigation的rootfragment `class CommunityRootFragment : BaseViewFragment() {

    private val mFragments = ArrayList<Fragment>()
    private val mTitles = arrayOf(
        "发现", "社区"
    )
    
    override fun getSubLayoutId(): Int = R.layout.fragment_community_root
    
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }
    
    private fun initView() {
        mFragments.add(CommunityFindFragment())
        mFragments.add(CommunityCommutFragment())
        community_root_pager!!.offscreenPageLimit = mFragments.size
        community_root_pager.adapter = MyPagerAdapter(parentFragmentManager, mTitles, mFragments)
        community_slidingTabLayout.setViewPager(community_root_pager)
    }
    

    }`

    opened by Lw1244204021 1
  • app:tl_textBold=

    app:tl_textBold="SELECT"的情况下,默认选中的第一项未加粗

    **app:tl_textBold="SELECT"**的情况下,默认选中的第一项未加粗,这个问题是没麻烦作者修复一下。 <com.flyco.tablayout.SlidingTabLayout android:id="@+id/stl_tab" android:layout_width="match_parent" android:layout_height="40dp" app:tl_divider_color="@color/transparent" app:tl_divider_padding="13dp" app:tl_divider_width="1dp" app:tl_indicator_color="@color/common_primary_color" app:tl_indicator_height="2dp" app:tl_indicator_width_equal_title="true" app:tl_tab_padding="15dp" app:tl_tab_space_equal="true" app:tl_textBold="SELECT" app:tl_textSelectColor="@color/common_text_title_color" app:tl_textUnselectColor="@color/common_text_explain_color" app:tl_textsize="15sp" app:tl_underline_color="@color/transparent" app:tl_underline_height="0dp" />

    opened by yongchao1210 3
Releases(v2.0.2)
Owner
Flyco
Flyco
Added support to modify text size and indicator width based on the original TabLayout.

XTabLayout——可修改选中项字体大小和指示器长度的TabLayout XTabLayout是基于design包中的TabLayout进行了功能的扩展,在保留原有功能的基础上,增加了修改选中项字体大小、修改指示器长度以及限制屏幕显示范围内显示的Tab个数。 集成步骤: 1.添加XTabLayo

Kennor 660 Dec 20, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Txus Ballesteros 1.5k Jan 2, 2023
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Please switch to DragView, for the best support, thank you DraggablePanel Download allprojects { repositories { ... maven { url 'https://jitp

Hoàng Anh Tuấn 103 Oct 12, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
A wave view of android,can be used as progress bar.

WaveView ![Gitter](https://badges.gitter.im/Join Chat.svg) A wave view of android,can be used as progress bar. Screenshot APK demo.apk What can be use

Kai Wang 1.3k Dec 28, 2022
An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu

ResideLayout An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu. Can be used on Android 1.6(I haven't try it.)

Yang Hui 392 Oct 12, 2022
An Android library that help you to build app with swipe back gesture.

SwipeBackLayout An Android library that help you to build app with swipe back gesture. Demo Apk GooglePlay Requirement The latest android-support-v4.j

ike_w0ng 6.1k Dec 29, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Nov 21, 2022
Ultra Pull to Refresh for Android. Support all the views.

Welcome to follow me on GitHub or Twitter GitHub: https://github.com/liaohuqiu Twitter: https://twitter.com/liaohuqiu 中文版文档 Wanna auto-load-more? This

Huqiu Liao 9.6k Jan 5, 2023
SwipeBack is an android library that can finish a activity by using gesture.

SwipeBack SwipeBack is a android library that can finish a activity by using gesture. You can set the swipe direction,such as left,top,right and botto

Eric 1.7k Nov 21, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022
Android layout that simulates physics using JBox2D

PhysicsLayout Android layout that simulates physics using JBox2D. Simply add views, enable physics, and watch them fall! See it in action with the sam

John Carlson 689 Dec 29, 2022
Android component which presents a dismissible view from the bottom of the screen

BottomSheet BottomSheet is an Android component which presents a dismissible view from the bottom of the screen. BottomSheet can be a useful replaceme

Flipboard 4.5k Dec 28, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Kai 615 Nov 14, 2022
Stale Android Toasts made tasty.

FrenchToast Stale Android Toasts made tasty. Android Toasts are amazing, but they have a few major drawbacks: You cannot control when they show up as

py - Pierre Yves Ricau 367 Nov 15, 2022
waveview for android

中文介绍 WaveView A view to display wave effect. Screenshot Integration implementation 'com.gelitenight.waveview:waveview:1.0.0' Setter methods: setWaveS

NIGHT 1.6k Dec 21, 2022
An Android demo of a foldable layout implementation. Engineered by Vincent Brison.

Foldable Layout This code is a showcase of a foldable animation I created for Worldline. The code is fully written with java APIs from the Android SDK

Worldline 599 Dec 23, 2022