RTL list fixes

This commit is contained in:
M66B 2021-05-06 10:35:56 +02:00
parent 9278fa2eef
commit 9c4d7b0312
2 changed files with 7 additions and 4 deletions

View File

@ -63,6 +63,6 @@ public class BulletSpanEx extends BulletSpan {
@Override
public void drawLeadingMargin(@NonNull Canvas canvas, @NonNull Paint paint, int x, int dir, int top, int baseline, int bottom, @NonNull CharSequence text, int start, int end, boolean first, @Nullable Layout layout) {
super.drawLeadingMargin(canvas, paint, x + indentWidth * level, dir, top, baseline, bottom, text, start, end, first, layout);
super.drawLeadingMargin(canvas, paint, x + indentWidth * level * dir, dir, top, baseline, bottom, text, start, end, first, layout);
}
}

View File

@ -28,12 +28,13 @@ import android.text.TextPaint;
import android.text.style.BulletSpan;
public class NumberSpan extends BulletSpan {
int indentWidth;
private int indentWidth;
private int level;
private int index;
private TextPaint tp;
private String number;
private int numberWidth;
private int margin;
public NumberSpan(int indentWidth, int gapWidth, int color, float textSize, int level, int index) {
@ -48,7 +49,8 @@ public class NumberSpan extends BulletSpan {
this.index = index;
number = index + ".";
margin = Math.round(tp.measureText(number)) + gapWidth;
numberWidth = Math.round(tp.measureText(number));
margin = numberWidth + gapWidth;
}
float getTextSize() {
@ -81,7 +83,8 @@ public class NumberSpan extends BulletSpan {
float textSize = tp.getTextSize();
if (textSize > p.getTextSize())
tp.setTextSize(p.getTextSize());
c.drawText(number, x + indentWidth * level, baseline, tp);
int offset = (dir < 0 ? numberWidth : 0);
c.drawText(number, x + indentWidth * level * dir - offset, baseline, tp);
tp.setTextSize(textSize);
}
}