Skip to content

Commit 789c7c5

Browse files
committed
1,修改demo
2,修改readme
1 parent 868870b commit 789c7c5

File tree

8 files changed

+57
-34
lines changed

8 files changed

+57
-34
lines changed

README-zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## 多数app登陆首页都需要显示用户协议和隐私政策并且需要能够点击,遇到需要翻译多个国家语言的,多个TextView拼接会导致语序不对,而且换行也是个问题
55

6-
<img src="https://github.com/FlyJingFish/FormatTextViewLib/blob/master/screenshot/Screenshot_20230113_192139.jpg" width="405px" height="842px" alt="show" />
6+
<img src="https://github.com/FlyJingFish/FormatTextViewLib/blob/master/screenshot/Screenrecording_20230116_164552.gif" width="405px" height="842px" alt="show" />
77

88
# 特色功能
99

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Most apps need to display the user agreement and privacy policy on the home page and need to be able to click. If you need to translate multiple national languages, the splicing of multiple TextViews will cause the word order to be wrong, and line breaks are also a problem.
88

9-
<img src="https://github.com/FlyJingFish/FormatTextViewLib/blob/master/screenshot/Screenshot_20230113_192139.jpg" width="405px" height="842px" alt="show" />
9+
<img src="https://github.com/FlyJingFish/FormatTextViewLib/blob/master/screenshot/Screenrecording_20230116_164552.gif" width="405px" height="842px" alt="show" />
1010

1111
# special function
1212

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
package com.flyjingfish.formattextviewdemo
22

33
import android.graphics.drawable.Drawable
4-
import androidx.appcompat.app.AppCompatActivity
54
import android.os.Bundle
6-
import android.text.style.ImageSpan
7-
import android.util.Log
85
import android.widget.Toast
6+
import androidx.appcompat.app.AppCompatActivity
97
import com.bumptech.glide.Glide
108
import com.bumptech.glide.RequestBuilder
119
import com.bumptech.glide.request.RequestOptions
1210
import com.bumptech.glide.request.target.CustomTarget
1311
import com.bumptech.glide.request.transition.Transition
14-
import com.flyjingfish.formattextview.FormatText
1512
import com.flyjingfish.formattextview.*
1613
import kotlinx.android.synthetic.main.activity_main.*
1714

1815
class DemoActivity : AppCompatActivity() {
1916
override fun onCreate(savedInstanceState: Bundle?) {
2017
super.onCreate(savedInstanceState)
2118
setContentView(R.layout.activity_demo)
22-
text1.setFormatTextBean("我已阅读并同意%1\$s和%2\$s",
19+
text1.setFormatTextBean(R.string.xieyi,
2320
FormatText().apply {
2421
textSize = 22f
2522
textColor = R.color.colorAccent
2623
bold = false
2724
italic = true
2825
underline = true
2926
underlineColor = R.color.color_red
30-
underlineMarginTop = 10f
27+
underlineMarginTop = 6f
3128
underlineWidth = 2f
32-
strValue = "《用户协议》"
29+
resValue = R.string.User_Agreement
3330
},
3431
FormatText().apply {
3532
textSize = 22f
@@ -38,9 +35,9 @@ class DemoActivity : AppCompatActivity() {
3835
italic = true
3936
underline = true
4037
underlineColor = R.color.colorAccent
41-
underlineMarginTop = 10f
38+
underlineMarginTop = 6f
4239
underlineWidth = 2f
43-
strValue = "《隐私政策》"
40+
resValue = R.string.Privacy_Policy
4441
}
4542
)
4643
text1.setOnFormatClickListener(object :OnFormatClickListener{
@@ -77,52 +74,52 @@ class DemoActivity : AppCompatActivity() {
7774
})
7875
}
7976
})
80-
text2.setFormatTextBean("%1\$s看到自己喜欢的卡通相册%4\$s原价%3\$s现价%2\$s",
77+
text2.setFormatTextBean(R.string.xiao_ming_book,
8178
FormatText().apply {
8279
textSize = 30f
8380
textColor = R.color.colorAccent
8481
bold = false
8582
italic = true
8683
resValue = R.string.ming
87-
},
88-
FormatText().apply {
89-
textSize = 30f
90-
textColor = R.color.black
91-
bold = false
92-
italic = true
93-
strValue = "¥120元"
94-
deleteLine = true
95-
deleteLineColor = R.color.color_red
96-
deleteLineWidth = 2f
84+
},FormatImage().apply {
85+
imagePlaceHolder = R.mipmap.ic_launcher_round
86+
imageUrlValue = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp0.itc.cn%2Fq_70%2Fimages03%2F20210227%2F6687c969b58d486fa2f23d8488b96ae4.jpeg&refer=http%3A%2F%2Fp0.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661701773&t=19043990158a1d11c2a334146020e2ce"
87+
verticalAlignment = FormatImage.ALIGN_CENTER
88+
width = 40f
89+
height = 40f
90+
marginStart = 10f
91+
marginEnd = 10f
9792
},
9893
FormatText().apply {
9994
textSize = 30f
10095
textColor = R.color.gray
10196
bold = true
10297
italic = true
103-
strValue = "¥200元"
98+
resValue = R.string.money_200
10499
underline = true
105100
underlineColor = R.color.colorPrimary
106101
underlineMarginTop = 10f
107102
underlineWidth = 3f
108103
},
109-
FormatImage().apply {
110-
imagePlaceHolder = R.mipmap.ic_launcher_round
111-
imageUrlValue = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp0.itc.cn%2Fq_70%2Fimages03%2F20210227%2F6687c969b58d486fa2f23d8488b96ae4.jpeg&refer=http%3A%2F%2Fp0.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661701773&t=19043990158a1d11c2a334146020e2ce"
112-
verticalAlignment = FormatImage.ALIGN_CENTER
113-
width = 40f
114-
height = 40f
115-
marginStart = 10f
116-
marginEnd = 10f
104+
FormatText().apply {
105+
textSize = 30f
106+
textColor = R.color.black
107+
bold = false
108+
italic = true
109+
resValue = R.string.money_120
110+
deleteLine = true
111+
deleteLineColor = R.color.color_red
112+
deleteLineWidth = 2f
117113
})
118114
text2.setOnFormatClickListener(object : OnFormatClickListener{
119115
override fun onLabelClick(position: Int) {
120-
Toast.makeText(this@DemoActivity,"onItemClick-item"+position,Toast.LENGTH_SHORT).show()
116+
Toast.makeText(this@DemoActivity,"onLabelClick-position="+position,Toast.LENGTH_SHORT).show()
121117
}
122118
})
123119
text2.setOnClickListener {
124120
Toast.makeText(this@DemoActivity,"onClick-view",Toast.LENGTH_SHORT).show()
125121
}
126122

127123
}
124+
128125
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5-
android:gravity="center"
5+
android:gravity="center_vertical"
66
android:padding="10dp"
77
android:orientation="vertical">
8+
89
<com.flyjingfish.formattextview.FormatTextView
910
android:id="@+id/text1"
1011
android:layout_width="wrap_content"
1112
android:layout_height="wrap_content"
1213
android:lineSpacingMultiplier="1.2"
1314
android:textSize="18sp"
1415
android:text="Hello World!" />
16+
17+
18+
<com.flyjingfish.formattextview.FormatTextView
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:textSize="18sp"
22+
android:textColor="@color/black"
23+
android:layout_marginTop="40dp"
24+
android:text="更多使用示例" />
1525
<com.flyjingfish.formattextview.FormatTextView
1626
android:id="@+id/text2"
1727
android:layout_width="wrap_content"
1828
android:layout_height="wrap_content"
1929
android:lineSpacingMultiplier="1.2"
20-
android:layout_marginTop="30dp"
2130
android:textSize="18sp"
2231
android:text="Hello World!" />
2332
</LinearLayout>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="xieyi">I have read and agree to %1$s and %2$s</string>
5+
<string name="User_Agreement">User Agreement</string>
6+
<string name="Privacy_Policy">Privacy Policy</string>
7+
<string name="xiao_ming_book">%1$s saw my favorite cartoon album %2$s original price %3$s current price %4$s</string>
8+
<string name="ming">Xiao ming</string>
9+
<string name="money_200">¥200</string>
10+
<string name="money_120">¥120</string>
11+
</resources>

app/src/main/res/values/strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
<string name="we">我们</string>
55
<string name="you">你</string>
66
<string name="ming">小明</string>
7+
<string name="xieyi">我已阅读并同意%1$s和%2$s</string>
8+
<string name="User_Agreement">用户协议</string>
9+
<string name="Privacy_Policy">隐私政策</string>
10+
<string name="xiao_ming_book">%1$s看到自己喜欢的卡通相册%2$s原价%3$s现价%4$s</string>
11+
<string name="money_200">¥200元</string>
12+
<string name="money_120">¥120元</string>
713
</resources>
1.91 MB
Loading
-226 KB
Binary file not shown.

0 commit comments

Comments
 (0)