TextView: make sure getPaint().getTextSize() returns the expected value

Using pango_font_description_set_absolute_size() now to prevent previous
rounding errors when converting from pixels to points and back.

This is needed to prevent androidx AppCompatTextViewAutoSizeHelper from
constantly requesting a relayout.
This commit is contained in:
Julian Winkler
2025-10-22 21:14:18 +02:00
parent 377c140d7c
commit 3b69e949d9
2 changed files with 4 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import android.view.View;
public class TextView extends View {
private ColorStateList colors = new ColorStateList(new int[][] {new int[0]}, new int[1]);
private CharSequence text = "";
private TextPaint paint = new TextPaint();
public TextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -158,7 +159,7 @@ public class TextView extends View {
public static ColorStateList getTextColors(Context context, TypedArray attrs) { return new ColorStateList(new int[][] {new int[0]}, new int[1]); }
public TextPaint getPaint() {
return new TextPaint();
return paint;
}
public void addTextChangedListener(TextWatcher watcher) {}