android - Getting extra space while using SpanningString -
i creating customview. need string spannable string, change colour of part of string. code compiles, there long space between string , part coloured.
here code :
string string = mstat1 + "" + mstatvalue1; spannablestring spannablestring = new spannablestring(string); if(mstatvalue1<=0) { spannablestring.setspan(new foregroundcolorspan(color.rgb(183,108,100)), mstat1.length(), string.length(), spanned.span_exclusive_exclusive); } else { spannablestring.setspan(new foregroundcolorspan(color.rgb(117,205,132)), mstat1.length(), string.length(), spannable.span_exclusive_exclusive); } textpaint textpaint = createtextpaint(mtextcolor, mstatsize, paint.align.center); mdynamiclayout = new dynamiclayout(spannablestring, textpaint, mwidthpix/2, layout.alignment.align_normal, 0.0f, 0.0f, false);
here image of view :
i need remove gap between coloured part of string , remaining string. thanks.
i think problem related lines:
textpaint textpaint = createtextpaint(mtextcolor, mstatsize, paint.align.center); mdynamiclayout = new dynamiclayout(spannablestring, textpaint, mwidthpix/2, layout.alignment.align_normal, 0.0f, 0.0f, false);
you changing color of text can use method textview#settextcolor(int color);
using 2 separate textview
views.
Comments
Post a Comment