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

栏目: IOS · Android · 发布时间: 7年前

内容简介:TabLayout 核心用法不变,新增一些自定义属性。Step 1.添加 JitPack 仓库在根目录 build.gradle 中添加:

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>
复制代码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

需求

需求

[美] 亚德里安•斯莱沃斯基(Adrian J. Slywotzky)、[美]卡尔•韦伯 (Karl Weber) / 魏薇、龙志勇 / 浙江人民出版社 / 2013-6 / 64.9

《财富汇•需求:缔造伟大商业传奇的根本力量》内容简介:需求,是缔造伟大商业传奇的根本力量。《财富汇•需求:缔造伟大商业传奇的根本力量》呈现了人们无法拒绝、竞争对手无法复制的需求创造的六大关键,在人们无奈接受的现状和心中真正期待的理想的这道鸿沟之上,架设起了一道桥梁。 创造需求,需要解开一个谜团,这个谜团是人类学、心理学、科技、设计、经济学、基础设施以及其他众多因素综合而成的奇特组合。《财富汇......一起来看看 《需求》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具