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);
    }

This component is used like:

<com.xxx.ui.widget.slice.SliceNutrientsSection
       android:id="@+id/nutrients"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"/>

Ps: if I take all the text to align it at right, it works, but with a part of text it doesn’t work…

Thank you by advance guys!