That's an interesting approach. I do not think that it will work in all cases. If you poke around at the logic for rendering text in TextView, you'll find a bunch of baked-in class references (e.g., getUrls() only uses UrlSpan, spell-check logic relies on SuggestionSpan), meaning that creating your own equivalents would be at least partially ignored by the rendering code. I'm glad to hear that this works at least for foreground colors, though.
On Thu, Oct 18, 2012 at 8:05 AM, Jan Burse <[email protected]> wrote: > Mark Murphy schrieb: > >> On Thu, Oct 18, 2012 at 5:35 AM, Jan Burse <[email protected]> wrote: >>> >>> How can I change the color? >> >> >> Use getSpans(), find all occurrences of your span, remove the old >> span, and replace it with a span with the new color. >> >> It's possible that there is a more efficient alternative than this, >> but I am not aware of one. >> > > I went for a custom class: > > public class MyForegroundColorSpan extends CharacterStyle > implements UpdateAppearance { > private int color; > > public int getForegroundColor() { > return color; > } > > public void setForegroundColor(int c) { > color = c; > } > > public void updateDrawState(TextPaint ds) { > ds.setColor(color); > } > > } > > Then using the setter and calling invalidate() on > the text view works like a charm. > > > Bye > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in NYC: http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

