Skip to content

Commit 1c91a9e

Browse files
committed
1,优化合并TextView代码
2,修改readme
1 parent afa1245 commit 1c91a9e

File tree

8 files changed

+438
-315
lines changed

8 files changed

+438
-315
lines changed

README.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,112 @@
11
# GradientTextView
2-
渐变色TextView
2+
## 支持字体渐变色,支持加渐变色粗边
3+
4+
[![](https://jitpack.io/v/FlyJingFish/GradientTextView.svg)](https://jitpack.io/#FlyJingFish/GradientTextView)
5+
6+
7+
<img src="https://github.com/FlyJingFish/GradientTextView/blob/master/screenshot/Screenshot_20221012_141234.jpg" width="405px" height="842px" alt="show" />
8+
9+
## 特色功能
10+
1,支持前景字体渐变色,支持设置渐变方向
11+
12+
2,支持设置字体背景粗边,粗边支持渐变色
13+
14+
3,同时支持以上两点混合
15+
16+
17+
## 第一步,根目录build.gradle
18+
19+
```gradle
20+
allprojects {
21+
repositories {
22+
...
23+
maven { url 'https://jitpack.io' }
24+
}
25+
}
26+
```
27+
## 第二步,需要引用的build.gradle (最新版本[![](https://jitpack.io/v/FlyJingFish/GradientTextView.svg)](https://jitpack.io/#FlyJingFish/GradientTextView)
28+
29+
```gradle
30+
dependencies {
31+
implementation 'com.github.FlyJingFish:GradientTextView:1.0'
32+
}
33+
```
34+
## 第三步,使用说明
35+
36+
**前景渐变颜色示例**
37+
38+
```xml
39+
<com.flyjingfish.gradienttextviewlib.GradientTextView
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:layout_margin="10dp"
43+
android:text=" Hello World! "
44+
android:textColor="@color/white"
45+
android:textSize="30sp"
46+
app:gradient_angle="0"
47+
app:gradient_endColor="@color/white"
48+
app:gradient_startColor="@color/teal_200"
49+
```
50+
51+
**粗边渐变颜色示例**
52+
53+
```xml
54+
<com.flyjingfish.gradienttextviewlib.GradientTextView
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_margin="10dp"
58+
android:text=" Hello World! "
59+
android:textColor="@color/white"
60+
android:textSize="30sp"
61+
app:gradient_stroke_angle="0"
62+
app:gradient_stroke_strokeWidth="6dp"
63+
app:gradient_stroke_textColor="@color/purple_700" />
64+
```
65+
66+
**前景粗边渐变颜色混合设置示例**
67+
68+
```xml
69+
<com.flyjingfish.gradienttextviewlib.GradientTextView
70+
android:layout_width="wrap_content"
71+
android:layout_height="wrap_content"
72+
android:layout_margin="10dp"
73+
android:text=" Hello World! "
74+
android:textColor="@color/white"
75+
android:textSize="30sp"
76+
app:gradient_angle="0"
77+
app:gradient_endColor="@color/white"
78+
app:gradient_startColor="@color/teal_200"
79+
app:gradient_stroke_angle="0"
80+
app:gradient_stroke_strokeWidth="6dp"
81+
app:gradient_stroke_textColor="@color/purple_700" />
82+
```
83+
84+
### 属性一览
85+
86+
|attr|format| description |
87+
|---|:---:|:-----------------------:|
88+
|gradient_startColor|color| 前景字体渐变颜色开始颜色 |
89+
|gradient_centerColor|color| 前景字体渐变颜色中心颜色 |
90+
|gradient_endColor|color| 前景字体渐变颜色结束颜色 |
91+
|gradient_angle|float| 前景字体渐变颜色开始角度 |
92+
|gradient_rtl_angle|boolean| 前景字体渐变颜色开始角度是否支持镜像Rtl适配 |
93+
|gradient_stroke_startColor|color| 字体粗边渐变颜色开始颜色 |
94+
|gradient_stroke_centerColor|color| 字体粗边渐变颜色中心颜色 |
95+
|gradient_stroke_endColor|color| 字体粗边渐变颜色结束颜色 |
96+
|gradient_stroke_angle|float| 字体粗边渐变颜色开始角度 |
97+
|gradient_stroke_rtl_angle|boolean| 字体粗边渐变颜色开始角度是否支持镜像Rtl适配 |
98+
|gradient_stroke_strokeWidth|dimension| 字体粗边画笔宽度 |
99+
|gradient_stroke_textColor|color| 字体粗边颜色(设置渐变色之后此属性无效) |
100+
101+
### 常见问题
102+
103+
1,如果使用粗边可能会存在左右两侧被切除一部分,可在字符串两侧添加空格解决问题
104+
105+
106+
# 最后推荐我写的另一个库,轻松实现在应用内点击小图查看大图的动画放大效果
107+
108+
- [OpenImage](https://github.com/FlyJingFish/OpenImage) (已内置当前库)
109+
110+
- [主页查看更多开源库](https://github.com/FlyJingFish)
111+
112+

app/src/main/res/layout/activity_main.xml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,56 @@
77
android:orientation="vertical"
88
tools:context=".MainActivity">
99

10-
<com.flyjingfish.gradienttextviewlib.GradientColorStrokeTextView
10+
<com.flyjingfish.gradienttextviewlib.GradientTextView
1111
android:layout_width="wrap_content"
1212
android:layout_height="wrap_content"
1313
android:layout_margin="10dp"
1414
android:text="Hello World!"
1515
android:textColor="@color/white"
16-
android:textSize="20sp"
17-
app:gradient_stroke_endColor="@color/white"
18-
app:gradient_stroke_startColor="@color/purple_700"
19-
app:gradient_stroke_strokeWidth="6dp" />
16+
android:textSize="30sp"
17+
app:gradient_angle="0"
18+
app:gradient_endColor="@color/purple_200"
19+
app:gradient_startColor="@color/teal_200" />
2020

21-
<com.flyjingfish.gradienttextviewlib.GradientColorStrokeTextView
21+
<com.flyjingfish.gradienttextviewlib.GradientTextView
2222
android:layout_width="wrap_content"
2323
android:layout_height="wrap_content"
2424
android:layout_margin="10dp"
2525
android:text="Hello World!"
2626
android:textColor="@color/white"
27-
android:textSize="20sp"
28-
app:gradient_stroke_endColor="@color/white"
29-
app:gradient_stroke_orientation="horizontal"
30-
app:gradient_stroke_startColor="@color/purple_700"
31-
app:gradient_stroke_strokeWidth="6dp" />
27+
android:textSize="30sp"
28+
app:gradient_angle="270"
29+
app:gradient_endColor="@color/purple_200"
30+
app:gradient_startColor="@color/teal_200" />
3231

33-
<com.flyjingfish.gradienttextviewlib.GradientColorTextView
32+
<com.flyjingfish.gradienttextviewlib.GradientTextView
3433
android:layout_width="wrap_content"
3534
android:layout_height="wrap_content"
3635
android:layout_margin="10dp"
37-
android:text="Hello World!"
36+
android:text=" Hello World! "
3837
android:textColor="@color/white"
39-
android:textSize="20sp"
38+
android:textSize="30sp"
39+
app:gradient_angle="0"
4040
app:gradient_endColor="@color/white"
41-
app:gradient_startColor="@color/purple_700" />
41+
app:gradient_startColor="@color/teal_200"
42+
app:gradient_stroke_angle="0"
43+
app:gradient_stroke_strokeWidth="6dp"
44+
app:gradient_stroke_textColor="@color/purple_700" />
4245

43-
<com.flyjingfish.gradienttextviewlib.GradientColorTextView
46+
<com.flyjingfish.gradienttextviewlib.GradientTextView
4447
android:layout_width="wrap_content"
4548
android:layout_height="wrap_content"
4649
android:layout_margin="10dp"
47-
android:text="Hello World!"
50+
android:text=" Hello World! "
4851
android:textColor="@color/white"
49-
android:textSize="20sp"
52+
android:textSize="30sp"
53+
android:textStyle="italic|bold"
54+
app:gradient_angle="270"
5055
app:gradient_endColor="@color/white"
51-
app:gradient_orientation="horizontal"
52-
app:gradient_startColor="@color/purple_700" />
56+
app:gradient_startColor="@color/teal_200"
57+
app:gradient_stroke_angle="0"
58+
app:gradient_stroke_endColor="@color/white"
59+
app:gradient_stroke_startColor="@color/purple_700"
60+
app:gradient_stroke_strokeWidth="6dp" />
5361

5462
</LinearLayout>

library/src/main/java/com/flyjingfish/gradienttextviewlib/BaseGradientTextView.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientColorStrokeTextView.java

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)