Giter Club home page Giter Club logo

tvtablayout's Introduction

欢迎使用 TvTabLayout Download

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

效果

Android Studio 集成

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

自定义属性

属性 值/类型 简介
tabIndicatorResId reference 指示器的资源(图片或颜色)
tabIndicatorWidth dimension 指示器的宽
tabIndicatorHeight dimension 指示器的高
tabIndicatorGravity top / center / bottom 指示器的位置
tabIndicatorBackgroundHeight dimension 指示器背景高度
tabIndicatorBackgroundColor color 指示器背景颜色
tabContentStart dimension 内容开始距离
tabContentBottom dimension 内容底部距离
tabCircleDotRadius dimension 小圆点的半径
tabCircleDotColor color / reference 小圆点的颜色
tabScrollMode scrollable / fixed 滚动模式
tabBackground reference tab背景
tabGravity top / center / bottom / fill tab的位置
tabMinWidth dimension tab最小宽度
tabMaxWidth dimension tab最大宽度
tabTexSize dimension 文本大小
tabTextColor color / reference 文本颜色
tabTextSelectedScale float 文本选中时的缩放比例
tabTextSelectedCentered boolean 文本选中时是否居中
tabPaddingStart dimension tab padding start
tabPaddingTop dimension tab padding top
tabPaddingEnd dimension tab padding end
tabPaddingBottom dimension tab padding bottom
tabPadding dimension tab 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

tvtablayout's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.