Tag Archives : android

Why my AlignmentSpan doesn’t work (line)?

By | Comments Off on Why my AlignmentSpan doesn’t work (line)?

From my TextView, I want to set a part of text at left and another part at right (on the same line!), but it doesn’t work. The text is always at left. public class SliceNutrientsSection extends AppCompatTextView { … private void setText(String text, int nameLength, int appearance) { SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE), nameLength, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); append(spannableString); }…

Read More »