Giter VIP home page Giter VIP logo

slidingtab's Introduction

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.

slidingtab's People

Contributors

vivian8725118 avatar daishengda2018 avatar

Watchers

James Cloos avatar

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.