From 03d8969045754ab9156c9ec3be0e67557a59ab12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Tue, 3 Sep 2024 14:19:56 +0200 Subject: [PATCH] Fix auto text size - Set minimum to 1 SP and max to 100 SP - Set max lines to 1 --- .../secuso/privacyfriendly2048/activities/Element.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java index 9ebd9b1..56a8a1e 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java @@ -22,11 +22,13 @@ import static org.secuso.privacyfriendly2048.helpers.ThemeResolverKt.GetColorInt; import static org.secuso.privacyfriendly2048.helpers.ThemeResolverKt.GetColorRes; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; +import android.util.TypedValue; import android.view.View; import org.secuso.privacyfriendly2048.R; @@ -54,12 +56,18 @@ public class Element extends androidx.appcompat.widget.AppCompatButton { int color; + @SuppressLint("RestrictedApi") public Element(Context c) { super(c); context = c; setAllCaps(false); setBackgroundResource(R.drawable.game_brick); setColor(GetColorRes(context, R.attr.buttonEmpty)); + setMaxLines(1); + setAutoSizeTextTypeUniformWithConfiguration(1, + 100, + 1, + TypedValue.COMPLEX_UNIT_SP); } public void drawItem() {