TvTabLayout 针对 Android Tv 端把原生的 tablayout 进行适配和改造

TvTabLayout

项目地址:zhousuqiang/TvTabLayout 

简介: TvTabLayout 针对 Android Tv 端把原生的 tablayout 进行适配和改造

更多:作者   提 Bug   

标签:

 

  • 针对 TV 端的特性对 TabLayout 进行了适配与开发;
  • 支持图片或颜色值作为 Indicator;

效果

 

Android Studio 集成

implementation 'com.owen:tv-tablayout:1.0.1'

自定义属性

属性值/类型简介
tabIndicatorResIdreference指示器的资源(图片或颜色)
tabIndicatorWidthdimension指示器的宽
tabIndicatorHeightdimension指示器的高
tabIndicatorGravitytop / center / bottom指示器的位置
tabIndicatorBackgroundHeightdimension指示器背景高度
tabIndicatorBackgroundColorcolor指示器背景颜色
tabContentStartdimension内容开始距离
tabContentBottomdimension内容底部距离
tabCircleDotRadiusdimension小圆点的半径
tabCircleDotColorcolor / reference小圆点的颜色
tabScrollModescrollable / fixed滚动模式
tabBackgroundreferencetab 背景
tabGravitytop / center / bottom / filltab 的位置
tabMinWidthdimensiontab 最小宽度
tabMaxWidthdimensiontab 最大宽度
tabTexSizedimension文本大小
tabTextColorcolor / reference文本颜色
tabTextSelectedScalefloat文本选中时的缩放比例
tabTextSelectedCenteredboolean文本选中时是否居中
tabPaddingStartdimensiontab padding start
tabPaddingTopdimensiontab padding top
tabPaddingEnddimensiontab padding end
tabPaddingBottomdimensiontab padding bottom
tabPaddingdimensiontab padding

使用

// 代码动态添加 tab
TvTabLayout mTabLayout = findViewById(R.id.tablayout);
for(int i=0; i<15; i++) {
    mTabLayout.addTab(mTabLayout.newTab().setText("标题"+i), i == 0);
}

// 布局直接指定 tab
<com.owen.tab.TvTabLayout
        android:id="@+id/tablayout3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="60dp"
        app:tabIndicatorResId="@drawable/zx_p1_light"
        app:tabIndicatorWidth="108dp"
        app:tabIndicatorHeight="15dp"
        app:tabIndicatorBackgroundColor="@color/color_88ff804B"
        app:tabIndicatorBackgroundHeight="3dp"
        app:tabMinWidth="160dp"
        app:tabScrollMode="fixed"
        app:tabGravity="center"
        app:tabPaddingBottom="12dp"
        app:tabTextSelectedScale="1.2"
        app:tabTexSize="22sp"
        app:tabTextColor="@drawable/selector_tab_font_color">

        <com.owen.tab.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="标题 1"/>

        <com.owen.tab.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="标题 2"/>

        <com.owen.tab.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="标题 3"/>

    </com.owen.tab.TvTabLayout>

// 监听设置
mTabLayout.addOnTabSelectedListener(new TvTabLayout.OnTabSelectedListener() {
    @Override
    public void onTabSelected(TvTabLayout.Tab tab) {

    }

    @Override
    public void onTabUnselected(TvTabLayout.Tab tab) {

    }

    @Override
    public void onTabReselected(TvTabLayout.Tab tab) {

    }
});

更详细的使用请见 exmaple


扣 扣 群:484790001(注:加群时请写明来源及目的)

 

其它作品

焦点框框架TvFocusBorder

TvRecyclerView 框架TvRecyclerView

Tv 控件TvWidget

作者 owen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值