yo creo que hay que hacer esto en el código. Tuve que crear una subclase LeadingMarginSpan para que esto funcione. Así es como lo hice.
private class NumberIndentSpan implements LeadingMarginSpan {
private final int gapWidth;
private final int leadWidth;
private final int index;
public NumberIndentSpan(int leadGap, int gapWidth, int index) {
this.leadWidth = leadGap;
this.gapWidth = gapWidth;
this.index = index;
}
public int getLeadingMargin(boolean first) {
return leadWidth + gapWidth;
}
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout l) {
if (first) {
Paint.Style orgStyle = p.getStyle();
p.setStyle(Paint.Style.FILL);
float width = p.measureText("4.");
c.drawText(index + ".", (leadWidth + x - width/2) * dir, bottom - p.descent(), p);
p.setStyle(orgStyle);
}
}
}
hacerse con su punto de vista, y lo utilizan como esto:
SpannableStringBuilder ssb = new SpannableStringBuilder();
for(String text : list) {
int contentStart = content.length();
content.append(text);
content.setSpan(new NumberIndentSpan(15, 15, number), contentStart, content.length(), 0);
}
TextView view = findViewById(R.id.....);
view.setText(ssb);
Espero que esto ayude a otros en busca de esta :-)
balas Obtención lugar de números :( –