3
3
import android .app .Activity ;
4
4
import android .graphics .BlurMaskFilter ;
5
5
import android .graphics .Color ;
6
+ import android .graphics .Typeface ;
6
7
import android .os .Bundle ;
7
8
import android .text .Layout ;
8
9
import android .text .TextPaint ;
@@ -47,18 +48,18 @@ public void updateDrawState(TextPaint ds) {
47
48
// 响应点击事件的话必须设置以下属性
48
49
tvAboutSpannable .setMovementMethod (LinkMovementMethod .getInstance ());
49
50
tvAboutSpannable .setText (new SpannableStringUtils .Builder ()
50
- .appendLine ("测试SpannableStringUtils" ).setBold (). setForegroundColor ( Color . YELLOW ). setBackgroundColor (Color .GRAY ).setAlign (Layout .Alignment .ALIGN_CENTER )
51
+ .appendLine ("测试SpannableStringUtils" ).setBackgroundColor ( Color . LTGRAY ). setBold (). setForegroundColor (Color .YELLOW ).setAlign (Layout .Alignment .ALIGN_CENTER )
51
52
.append ("测试" )
52
53
.append ("前景色" ).setForegroundColor (Color .GREEN )
53
- .appendLine ("背景色" ).setBackgroundColor (Color .RED )
54
+ .appendLine ("背景色" ).setBackgroundColor (Color .LTGRAY )
54
55
.appendLine ("测试首行缩进" ).setLeadingMargin (30 , 50 )
55
- .appendLine ("测试引用" ).setQuoteColor (Color .BLACK )
56
- .appendLine ("测试列表项" ).setBullet (30 , Color . BLACK )
56
+ .appendLine ("测试引用" ).setQuoteColor (Color .BLUE , 10 , 10 )
57
+ .appendLine ("测试列表项" ).setBullet (Color . GREEN , 30 , 10 )
57
58
.appendLine ("测试32dp字体" ).setFontSize (36 , true )
58
59
.append ("测试" )
59
- .appendLine ("2倍字体" ).setFontProportion (2 )
60
+ .appendLine ("2倍字体" ).setProportion (2 )
60
61
.append ("测试" )
61
- .appendLine ("横向2倍字体" ).setFontXProportion (2 )
62
+ .appendLine ("横向2倍字体" ).setXProportion (2 )
62
63
.append ("测试" )
63
64
.append ("删除线" ).setStrikethrough ()
64
65
.appendLine ("下划线" ).setUnderline ()
@@ -70,13 +71,23 @@ public void updateDrawState(TextPaint ds) {
70
71
.append ("斜体" ).setItalic ()
71
72
.appendLine ("粗斜体" ).setBoldItalic ()
72
73
.appendLine ("monospace font" ).setFontFamily ("monospace" )
73
- .appendLine ("serif font" ).setFontFamily ("serif" )
74
- .appendLine ("sans-serif font" ).setFontFamily ("sans-serif" )
75
- .appendLine ("测试正常对齐" ).setAlign (Layout .Alignment .ALIGN_NORMAL )
76
- .appendLine ("测试居中对齐" ).setAlign (Layout .Alignment .ALIGN_CENTER )
74
+ .appendLine ("测试自定义字体" ).setTypeface (Typeface .createFromAsset (getAssets (), "fonts/dnmbhs.ttf" ))
77
75
.appendLine ("测试相反对齐" ).setAlign (Layout .Alignment .ALIGN_OPPOSITE )
78
- .append ("测试" )
79
- .appendLine ("图片" ).setResourceId (R .mipmap .ic_launcher )
76
+ .appendLine ("测试居中对齐" ).setAlign (Layout .Alignment .ALIGN_CENTER )
77
+ .appendLine ("测试正常对齐" ).setAlign (Layout .Alignment .ALIGN_NORMAL )
78
+ .append ("测试小图对齐" ).setBackgroundColor (Color .LTGRAY )
79
+ .append ("image" ).setResourceId (R .drawable .shape_block_low , SpannableStringUtils .ALIGN_TOP )
80
+ .append ("image" ).setResourceId (R .drawable .shape_block_low , SpannableStringUtils .ALIGN_CENTER )
81
+ .append ("image" ).setResourceId (R .drawable .shape_block_low , SpannableStringUtils .ALIGN_BASELINE )
82
+ .appendLine ("image" ).setResourceId (R .drawable .shape_block_low , SpannableStringUtils .ALIGN_BOTTOM )
83
+ .append ("测试顶部对齐" ).setBackgroundColor (Color .GREEN )
84
+ .appendLine ("image" ).setResourceId (R .drawable .shape_block_high , SpannableStringUtils .ALIGN_TOP )
85
+ .append ("居中对齐" ).setBackgroundColor (Color .LTGRAY )
86
+ .appendLine ("image" ).setResourceId (R .drawable .shape_block_high , SpannableStringUtils .ALIGN_CENTER )
87
+ .append ("Baseline对齐" ).setBackgroundColor (Color .GREEN )
88
+ .appendLine ("image" ).setResourceId (R .drawable .shape_block_high , SpannableStringUtils .ALIGN_BASELINE )
89
+ .append ("底部对齐" ).setBackgroundColor (Color .LTGRAY )
90
+ .appendLine ("image" ).setResourceId (R .drawable .shape_block_high , SpannableStringUtils .ALIGN_BOTTOM )
80
91
.append ("测试" )
81
92
.appendLine ("点击事件" ).setClickSpan (clickableSpan )
82
93
.append ("测试" )
0 commit comments