close
 TextView TV = (TextView)findViewById(R.id.mytextview01);
 Spannable word = new SpannableString("Your message");        

 word.setSpan(new ForegroundColorSpan(Color.BLUE), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

 TV.setText(word);
 Spannable wordTwo = new SpannableString("Your new message");        

 wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 TV.append(wordTwo);

 

BackgroundColorSpan => For background color!

 

HTML format insert to code:

String text = "<font color=#cc0029>Erste Farbe</font> <font color=#ffcc00>zweite Farbe</font>";
yourtextview.setText(Html.fromHtml(text));
arrow
arrow
    文章標籤
    Android Textview Color
    全站熱搜

    lionlionchopper 發表在 痞客邦 留言(0) 人氣()