Android开发之头部Tab(SlidingTabLayout使用)

使用心得,勿喷;

1、添加资源:

/**
 *  FlycoTabLayout(TabLayout库)
 */
implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'

2、文件布局:

<com.flyco.tablayout.SlidingTabLayout
    android:id="@+id/smart_table"
    android:layout_width="match_parent"
    android:layout_height="@dimen/base40dp"
    app:tl_divider_color="@android:color/transparent"
    app:tl_divider_width="0dp"
    app:tl_indicator_color="@color/colorAccent"
    app:tl_indicator_corner_radius="@dimen/base5dp"
    app:tl_indicator_height="@dimen/base4dp"
    app:tl_indicator_width="@dimen/base25dp"
    app:tl_tab_padding="@dimen/base15dp"
    app:tl_tab_space_equal="true"
    app:tl_textBold="BOTH"
    app:tl_textSelectColor="@color/colorText"
    app:tl_textUnselectColor="@color/colorText"
    app:tl_textsize="@dimen/base13sp"
    app:tl_underline_color="@color/colorLine"
    app:tl_underline_height="1px" />

<androidx.viewpager.widget.ViewPager
    android:id="@+id/smart_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

3、java代码:

smart_table.setViewPager(smart_pager, new title["标题一","标题一","标题一","标题一"], (FragmentActivity) mContext, fragments);
smart_pager.setOffscreenPageLimit(0);//预加载

完成,代码就是这样,不明白请留言

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值