New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

io.github.weilianyang:gradienttext

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io.github.weilianyang:gradienttext

Used to set the font gradient color, gradient direction, and animation effect of the TexView.

1.0.3
Source
Maven
Version published
Maintainers
1
Source

GradientTextView

Maven Central API License

🔥🔥🔥用于设置TexView的字体 渐变颜色渐变方向动画效果

添加依赖

buildscript {
    repositories {
        mavenCentral()
    }
}

implementation 'io.github.weilianyang:gradienttext:1.0.3'

效果预览:

效果动图 效果静态图

一、控件样式

<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_directionleftToRight:从左向右,topToBottom:从上向下渐变颜色的方向(默认值:leftToRight)
gradient_animatetrue or false渐变颜色的动画开关(默认值:false)
gradient_speedslow、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(this).apply {
    layoutParams =
        ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 100)
            .apply {
                topToTop = ConstraintLayout.LayoutParams.PARENT_ID
                topMargin = 100
                leftMargin = 100
            }
    this.text = "text"
    this.textSize = 18f

    this.direction = GradientTextView.leftToRight
    this.translateSpeed = GradientTextView.normal
    this.translateAnimate = true

    setColor(
        ContextCompat.getColor(this@SecondActivity, R.color.color_03DAC5),
        ContextCompat.getColor(this@SecondActivity, R.color.color_6200EE)
    )
}

五、控制动画开关

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

FAQs

Package last updated on 09 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts