Skip to content
可以交叉tab和文字的SlidingTab
Java
Branch: master
Clone or download
Latest commit 17c6dbf Dec 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
gradle/wrapper Initial commit Dec 10, 2019
slidingtab
.gitignore
README.md
README_EN.md update README Dec 13, 2019
build.gradle update README Dec 13, 2019
gradle.properties
gradlew
gradlew.bat Initial commit Dec 10, 2019
settings.gradle

README.md

SlidingTab

可以交叉tab和文字的SlidingTab,支持设置渐变色。

ENGLISH_VERSION_README

功能

1.支持底色交叉文字

2.支持渐变色

3.支持颜色修改

使用

1、导入包

implementation 'com.vivian.widgets:slidingtab:1.0.4'

2、 在xml中设置

<com.vivian.slidingtab.SlidingTab
        android:id="@+id/sliding_tab"
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        app:strokeWidth="2dp"
        app:mainColor="#1A51AD"
        app:mainColorRes="@color/colorAccent"
        app:radius="100dp"
        app:tabHeight="100dp"
        app:textSize="16sp"
        app:startColor="#a1aa0b"
        app:endColor="#1F8F70"
        android:layout_gravity="center"
        android:layout_height="wrap_content"/>
    app:strokeWidth="2dp"   //设置外围线框宽度
    app:mainColor="#1A51AD"  //设置主色
    app:mainColorRes="@color/colorAccent"  //设置主色资源。如果mainColor和mainColorRes同时设置了,按mainColorRes内容显示
    app:radius="100dp"  //设置圆角尺寸
    app:tabHeight="100dp" //设置tab高度
    app:textSize="16sp"  //设置字体大小
    app:startColor="#a1aa0b"  //设置渐变色起始颜色
    app:endColor="#1F8F70"   //设置渐变色结束颜色

3、 在java中设置

3.1 设置titles

slidingTab.setTitles("课程", "文档");

或者

slidingTab.setTitles(List<String> titles) 

3.2 绑定ViewPager的onPageChangeListener

slidingTab.bindViewPager(viewPager);

3.3 设置OnTabClickListener

 slidingTab.setOnTabClickListener(new SlidingTab.OnTabClickListener() {
            @Override
            public void onTabClick(int position) {
                viewPager.setCurrentItem(position);
            }
  });

License

Copyright 2019 Vivian

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.