File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# TextTagSpan
2- 在TextView中使用文本添加自定义标签,支持功能如下:
2+ 在TextView中使用文本添加自定义标签,
3+ ![ image] ( https://github.com/sixgodIT/TextTagSpan/blob/master/Screenshot.png )
34
5+ 支持:
461 . 可在文本任何位置添加文字标签
572 . 标签可设置文字大小、文字颜色、边框颜色、边框宽度、边框圆角
683 . 标签也可直接设置drawable背景
794 . 边框可设置左右间距
8105 . 支持设置行间距后,每一行标签都居中显示。
11+
12+ ### 使用
13+ TextTagSpan构造方法指定宽高,可使用drawable作为背景
14+
15+ ```
16+ TextTagSpan span = new TextTagSpan(this, dip2px(25), dip2px(15))
17+ .setRightMargin(dip2px(5))
18+ .setTextColor(Color.BLACK)
19+ .setTextSize(sp2px(11))
20+ .setBackground(R.drawable.tag_bacground);
21+ ```
22+
23+ 也可直接设置背景边框颜色、边框宽度和圆角
24+
25+ ```
26+ TextTagSpan span = new TextTagSpan(this, dip2px(25), dip2px(15))
27+ .setLeftMargin(dip2px(5))
28+ .setTextColor(Color.RED)
29+ .setTextSize(sp2px(13))
30+ .setRadius(dip2px(3))
31+ .setStrokeWidth(dip2px(0.5f))
32+ .setStrokeColor(Color.RED);
33+ ```
34+
35+ 结合** Truss** 使用更加方便。Truss使用参考:https://gist.github.com/JakeWharton/11274467
You can’t perform that action at this time.
0 commit comments