如上图所示闪闪发光字体:

HTextView 来源于

implementation 'com.hanks:htextview-base:0.1.2'
public class RainbowTextView extends HTextView {private Matrix mMatrix;
    private float mTranslate;
    private float colorSpeed;
    private float colorSpace;
    private int[] colors = {0XFF13C0FD, 0XFF11B2F7, 0XFF0D9BEE, 0XFF0984E6, 0XFF0879E1};
    private LinearGradient mLinearGradient;

    public RainbowTextView(Context context) {this(context, null);
    }public RainbowTextView(Context context, AttributeSet attrs) {this(context, attrs, 0);
    }public RainbowTextView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);
        init(attrs, defStyleAttr);
    }@Override
    public void setAnimationListener(AnimationListener listener) {throw new UnsupportedOperationException("Invalid operation for rainbow");
    }private void init(AttributeSet attrs, int defStyleAttr) {TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.RainbowTextView);
        colorSpace = typedArray.getDimension(R.styleable.RainbowTextView_colorSpace, DisplayUtils.dp2px(150));
        colorSpeed = typedArray.getDimension(R.styleable.RainbowTextView_colorSpeed, DisplayUtils.dp2px(5));
        typedArray.recycle();

        mMatrix = new Matrix();
        initPaint();
    }public float getColorSpace() {return colorSpace;
    }public void setColorSpace(float colorSpace) {this.colorSpace = colorSpace;
    }public float getColorSpeed() {return colorSpeed;
    }public void setColorSpeed(float colorSpeed) {this.colorSpeed = colorSpeed;
    }public void setColors(int... colors) {this.colors = colors;
        initPaint();
    }private void initPaint() {int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        measure(w, h);
        int height = getMeasuredHeight();
        mLinearGradient = new LinearGradient(0, 0, 0, height, colors, new float[]{0, 0.25f, 0.5f, 0.75f, 1.0f}, Shader.TileMode.MIRROR);
        getPaint().setShader(mLinearGradient);
    }@Override
    public void setProgress(float progress) {}@Override
    public void animateText(CharSequence text) {setText(text);
    }@Override
    protected void onDraw(Canvas canvas) {if (mMatrix == null) {mMatrix = new Matrix();
        }mTranslate += colorSpeed;
        mMatrix.setTranslate(0, mTranslate);
        mLinearGradient.setLocalMatrix(mMatrix);
        super.onDraw(canvas);
        postInvalidateDelayed(100);
    }

Android闪闪发光字体相关推荐

  1. Android闪闪发光字体Shimmer效果

    Android闪闪发光字体Shimmer效果 Shimmer是一款可以实现字体的闪闪发光加载效果的工具,本来是针对iOS开发实现,现在有朋友做成了安卓版本,实现的核心部分是使用线性渐变LinearGr ...

  2. Android闪闪发光字体效果

    Facebook开源了一款载入效果工具Shimmer,能够实现字体的闪闪发光效果,效果例如以下 链接地址在这里https://github.com/facebook/Shimmer,只是是针对iOS开 ...

  3. android 字体渲染机制,Android:字体渲染问题.ttf 3MB

    我的Android应用程序需要支持各种语言(如中文等).他们大多数都在Ascender的DroidSansFallback.ttf文件中.Android:字体渲染问题.ttf> 3MB 在某些A ...

  4. android 自定义字体_Android自定义字体教程

    android 自定义字体 In this tutorial, we'll explain how to set up android custom fonts in TextViews and Bu ...

  5. Android 中文字体的设置方法和使用技巧

    Android TextView字体颜色等样式具体解释连接:http://blog.csdn.net/pcaxb/article/details/47341249 1.使用字体库(自己定义字体的使用) ...

  6. android 获取默认字体,Android默认字体

    Android默认字体 (2012-03-09 17:29:53) 标签: 杂谈 分类: APP 简言之三种: monospace:sans: serif. 并有四种表现形式:正常:斜体:粗体:粗斜体 ...

  7. Android系统字体加载流程

    一.背景 视觉同学提了一个需求,要求手机中显示的字体可以支持medium字体,经过分析,android原生的字体库中并没有中文的medium字体,如果使用bold,显示又太粗,为满足需求,需要分析an ...

  8. android 设置字体大小不随系统大小变化,App字体大小不随系统改变而改变

    在 "设置" , "显示" , "字体大小" 里面我们可以设置系统字体大小 App界面字体,如果被修改之后,可能就达不到理想状态的效果,界面 ...

  9. android 标题字体大小,如何修改android studio标题字体大小

    匿名用户 1级 2017-03-08 回答 之前为大家讲解了android studio怎么修改字体大小和颜色?其实android studio代码字体样设置位置和之前将的设置位置是一样的,这里再给大 ...

  10. Android UI 字体库(.ttf文件)的使用 -- xml方式

    Android 8.0(API 级别 26)引入了"XML 中的字体"这项新功能, 可以在 res/font/ 文件夹中添加 font 文件. 要访问字体资源,请使用 @font/ ...

最新文章

  1. TypeError(“cannot concatenate ‘str‘ and ‘instancemethod‘ objects“,)
  2. js_高级_表格排序案例---分别用面向过程和面向对象实现
  3. FMS3系列学习网上教程
  4. lightingJS
  5. ultraedit中换行键的替换
  6. AuxreRP教学网站创始人郑建国:发挥Axure和原型真正的价值
  7. esp8266 php 接口,ESP8266_SDK基础(5)智能插座_完整项目代码
  8. 单片机控制灯光亮度c语言程序,基于51单片机控制LED灯光亮度并报警
  9. matlab 画箱线图boxplot简单用法
  10. 理解Spring框架中Bean的作用域
  11. 二元函数泰勒公式例题_考研.泰勒公式的理解与运用.一次全懂
  12. 使用python实现深度神经网络--学习笔记
  13. linux运行多线程语句,linux多线程中使用system函数后时而程序崩溃,求助!!!...
  14. 【雷达信号处理基础】第1讲 -- 雷达系统概述
  15. 微信小程序学习资料——转载
  16. EPLAN电气工程图纸EPLAN电气工程图纸,标准化程度高
  17. C++学习笔记——C++中四个点代表什么意思?
  18. supervisor详解-苏坡外泽
  19. .net core 3.1JWT用户权限认证(二)获取token
  20. 红皮书数据库的学习总结

热门文章

  1. win7 计算机 其他 删除,win7双系统怎么删除一个?windows7双系统删除一个方法汇总...
  2. 2018年年底PC浏览器使用率
  3. 向上滚动的文字的淡入淡出效果
  4. matlab中ix是什么意思,详解pandas中iloc, loc和ix的区别和联系
  5. mysql获取年龄_sql获取时间、年龄
  6. 计算机 去掉快捷方式箭头,去掉桌面快捷方式小箭头方法(无需修改注册表)
  7. 阿里聚石塔限制IP 过部署服务器详细流程
  8. wordpress主题_20种色彩缤纷的WordPress主题组合(免费和高级)
  9. startActivitystartActivities有什么不同?
  10. vue 用echarts写的进度条组件