Code Monkey home page Code Monkey logo

tablayout-android's Introduction

tablayout-android

修改 support 包 TabLayout,实现新浪微博/即刻 APP 蚯蚓导航效果

用法

TabLayout 核心用法不变,新增一些自定义属性。

<!-- 导航条 indicator 渐变开始颜色 -->
<attr name="indicatorStartColor" format="color"/>
<!-- 导航条 indicator 渐变结束颜色 -->
<attr name="indicatorEndColor" format="color"/>
<attr name="indicatorMarginStart" format="dimension"/>
<attr name="indicatorMarginEnd" format="dimension"/>
<attr name="indicatorMarginBottom" format="dimension"/>

1. 引入 lib

Step 1. 添加 JitPack 仓库

在根目录 build.gradle 中添加:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. 添加依赖

dependencies {
    implementation 'com.github.auv1107:tablayout-android:-SNAPSHOT'
}

2. 布局

只需要把你原来使用的 TabLayout 替换为 com.antiless.support.widget.TabLayout,即可启用蚯蚓动画效果。然后加上一些自定义 indicator 属性,来实现你的自定义样式。

<com.antiless.support.widget.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="wrap_content"
    android:layout_height="56dp"
    android:layout_gravity="center_horizontal"
    app:tabMode="scrollable"
    app:tabIndicatorHeight="3dp"
    app:indicatorStartColor="#d6694e"
    app:indicatorEndColor="#e73820"
    app:indicatorMarginStart="20dp"
    app:indicatorMarginEnd="20dp"
    app:indicatorMarginBottom="3dp">
</com.antiless.support.widget.TabLayout>

3. 代码

参考 TabLayout 核心用法。

TabLayout | Android Developers

从 TabLayout 的改动

改动很少,都在这个 patch 里了

Changes for earthworm TabLayout.

d81c7e1

tablayout-android's People

Watchers

James Cloos avatar  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.