88import android .text .SpannableStringBuilder ;
99import android .text .Spanned ;
1010import android .text .style .ForegroundColorSpan ;
11+ import android .text .style .StrikethroughSpan ;
1112import android .text .style .UnderlineSpan ;
1213import android .view .LayoutInflater ;
1314import android .view .View ;
@@ -32,22 +33,23 @@ protected void onCreate(Bundle savedInstanceState) {
3233 super .onCreate (savedInstanceState );
3334 setContentView (R .layout .activity_main );
3435 textView = (EasyTextView ) findViewById (R .id .easyText );
35- SpannableStringBuilder stringBuilder = new SpannableStringBuilder ("呵呵呵呵呵" );
36+ /* SpannableStringBuilder stringBuilder = new SpannableStringBuilder("呵呵呵呵呵");
3637 stringBuilder.setSpan(new UnderlineSpan(), 1, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
3738 SpannableStringBuilder insert = new SpannableStringBuilder("你好啊啊啊");
3839 insert.setSpan(new UnderlineSpan(), 1, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
39- stringBuilder .insert (0 , insert );
40+ stringBuilder.insert(0, insert);*/
4041 /*TextView text = (TextView) findViewById(R.id.text);
4142 SpannableStringBuilder stringBuilder = new SpannableStringBuilder("呵呵呵呵呵");
4243 SpannableStringBuilder insert = new SpannableStringBuilder("你好啊啊啊");
4344 insert.setSpan(new UnderlineSpan(), 1, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
4445 stringBuilder.insert(0, insert);
4546 text.setText(stringBuilder);*/
4647 //textView.setTextRight(insert);
47- textView .setTextRight ("啊啊啊啊" );
48- textView .addSpanLeft (new ForegroundColorSpan (Color .RED ), 0 , 1 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
49- textView .spanRight (new ForegroundColorSpan (Color .RED ), 0 , 1 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
50- .spanRight (new ForegroundColorSpan (Color .YELLOW ), 1 , 2 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
48+ textView .spanLeft (new UnderlineSpan (), 0 , 1 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
49+ .spanLeft (new StrikethroughSpan (), 1 , 2 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
50+ .spanLeft (new ForegroundColorSpan (Color .RED ), 1 , 2 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
51+ .spanRight (new ForegroundColorSpan (Color .RED ), 0 , 1 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
52+ .spanRight (new ForegroundColorSpan (Color .BLUE ), 1 , 2 , Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
5153 .build ();
5254 textView .setOnClickListener (new View .OnClickListener () {
5355 @ Override
0 commit comments