Skip to content

Repository files navigation

GradientTextView

支持字体渐变色,支持加渐变色粗边

GitHub starsGitHub forksGitHub issuesGitHub license

show

特色功能

新增继承 PerfectTextView

继承PerfectTextView 可使用其所有功能,您可前往查看如何使用点这里查看

1,支持前景字体渐变色,支持设置渐变方向

2,支持设置字体背景粗边,粗边支持渐变色

3,同时支持以上两点混合

4,所有颜色支持 ColorStateList

第一步,根目录build.gradle

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

第二步,需要引用的build.gradle (最新版本

dependencies {
implementation 'com.github.FlyJingFish:GradientTextView:1.2.5'
}

第三步,使用说明

前景渐变颜色示例

<com.flyjingfish.gradienttextviewlib.GradientTextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="10dp"android:text=" Hello World! "android:textColor="@color/white"android:textSize="30sp"app:gradient_angle="0"app:gradient_endColor="@color/white"app:gradient_startColor="@color/teal_200"

粗边渐变颜色示例

<com.flyjingfish.gradienttextviewlib.GradientTextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="10dp"android:text=" Hello World! "android:textColor="@color/white"android:textSize="30sp"app:gradient_stroke_angle="0"app:gradient_stroke_strokeWidth="6dp"app:gradient_stroke_textColor="@color/purple_700" />

前景粗边渐变颜色混合设置示例

<com.flyjingfish.gradienttextviewlib.GradientTextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="10dp"android:text=" Hello World! "android:textColor="@color/white"android:textSize="30sp"app:gradient_angle="0"app:gradient_endColor="@color/white"app:gradient_startColor="@color/teal_200"app:gradient_stroke_angle="0"app:gradient_stroke_strokeWidth="6dp"app:gradient_stroke_textColor="@color/purple_700" />

番外:如果你需要自定义加粗的粗细程度,只需要将粗边的颜色配置和字体一样,然后就可以随意设置粗边宽度了,如此一来加粗效果就是自定义的了

XML 属性一览

attrformatdescription
gradient_startColorcolor/reference前景字体渐变颜色开始颜色
gradient_centerColorcolor/reference前景字体渐变颜色中心颜色
gradient_endColorcolor/reference前景字体渐变颜色结束颜色
gradient_anglefloat前景字体渐变颜色开始角度
gradient_rtl_angleboolean前景字体渐变颜色开始角度是否支持镜像Rtl适配
gradient_stroke_startColorcolor/reference字体粗边渐变颜色开始颜色
gradient_stroke_centerColorcolor/reference字体粗边渐变颜色中心颜色
gradient_stroke_endColorcolor/reference字体粗边渐变颜色结束颜色
gradient_stroke_anglefloat字体粗边渐变颜色开始角度
gradient_stroke_rtl_angleboolean字体粗边渐变颜色开始角度是否支持镜像Rtl适配
gradient_stroke_strokeWidthdimension字体粗边画笔宽度
gradient_stroke_textColorcolor/reference字体粗边颜色(设置粗边渐变色之后此属性无效,设置此属性后粗边渐变色也失效)
gradient_stroke_joinenum字体粗边样式 round/bevel/miter 具体效果自行尝试

代码配置

请自行探索代码中设置颜色的配置方法

最后推荐我写的另外一些库

About

🔥🔥🔥渐变色GradientTextView,支持字体渐变色,支持渐变色粗边

Resources

Stars

56 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages