Github: TabLayout – Android

Modified support package TabLayout to achieve sina Weibo/Jike APP earthworm navigation effect

usage

The core usage of TabLayout remains unchanged, with some new custom properties.

<! -- Navigation bar Indicator Gradient start color -->
<attr name="indicatorStartColor" format="color"/>
<! -- Navigation bar Indicator End color -->
<attr name="indicatorEndColor" format="color"/>
<attr name="indicatorMarginStart" format="dimension"/>
<attr name="indicatorMarginEnd" format="dimension"/>
<attr name="indicatorMarginBottom" format="dimension"/>
Copy the code

1. Introduce the lib

Step 1. Add the JitPack repository

In the root directory build.gradle add:

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

Step 2. Add dependencies

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

2. Layout

Just need to have replaced the TabLayout that you use for the com. Antiless. Support. Widget. TabLayout, to enable the earthworm animation effects. Then add custom Indicators to implement your custom styles.

<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>
Copy the code

3. Code

Refer to the TabLayout core usage.

TabLayout | Android Developers

Changes from TabLayout

Very few changes, all in this patch.

Changes for earthworm TabLayout.

d81c7e1