GradientTextView Github点我

一个非常好用的库,使用kotlin实现,用于设置TexView的字体 渐变颜色渐变方向动画效果

添加依赖

implementation 'com.williamyang:gradienttext:1.0.1'

效果预览:


一、控件样式

<declare-styleable name="GradientTextView">    <attr name="gradient_startColor" format="reference|color" />    <attr name="gradient_endColor" format="reference|color" />    <attr name="gradient_direction" format="enum">        <enum name="leftToRight" value="1" />        <enum name="topToBottom" value="2" />    attr>    <attr name="gradient_animate" format="boolean" />    <attr name="gradient_speed" format="enum">        <enum name="slow" value="20" />        <enum name="normal" value="10" />        <enum name="fast" value="5" />    attr>declare-styleable>

二、属性介绍

属性 可选值 作用
gradient_startColor 值在color.xml中定义 渐变颜色的起始值(默认值:#6200EE)
gradient_endColor 值在color.xml中定义 渐变颜色的结束值(默认值:#03DAC5)
gradient_direction leftToRight:从左向右,topToBottom:从上向下 渐变颜色的方向(默认值:leftToRight)
gradient_animate true or false 渐变颜色的动画开关(默认值:false)
gradient_speed slow、normal、fast 渐变颜色的动画速度(默认值:normal)

三、控件在布局中使用

<com.william.gradient.GradientTextView    android:id="@+id/gradientTextView"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_marginTop="20dp"    android:text="@string/leftToRight_GradientTextView"    android:textSize="24sp"    app:gradient_animate="true"    app:gradient_direction="leftToRight"    app:gradient_speed="normal" />

四、在代码中控制动画开关

gradientTextView.apply {    translateAnimate = !translateAnimate    invalidate()}

更多相关文章

  1. Android开机界面
  2. Android(安卓)ListView 去除各种颜色问题
  3. Android之玩转MPAndroidChart让(折线图、柱形图、饼状图、散列图
  4. Android(安卓)Animation 详解
  5. ANDROID开机动画bootanimation.zip的详细制作方法
  6. Android开机动画详解
  7. android logo、android开机动画改变详解
  8. Android(安卓)Animation学习笔记
  9. ANDROID:LISTVIEW 自定义背景

随机推荐

  1. android 模态与非模态对话框实现
  2. Android(安卓)自定义button简单示例
  3. android的几种网络请求方式详解
  4. Android(安卓)屏幕适配之屏幕分辨率(创建
  5. Android 中 java 与 webview 的交互
  6. 安卓入门及界面带参数跳转
  7. android studio 获取签名(秘钥口令android
  8. Android(安卓)Studio安装过程中出现Faile
  9. Android 4高级编程(第三版)Android简介
  10. Android学习笔记十五之TableLayout表格布