Autoscale Textsize in Chip Android

150 views Asked by At

I am struggeling to find a way how to autoScale the Textsize in chips. The chips are inside a linearlayout.

            <com.google.android.material.chip.Chip
                android:id="@+id/tv_duration"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="120 min"
                android:textColor="@color/primaryColor"
                card_view:chipBackgroundColor="@color/green"
                card_view:chipIcon="@drawable/ic_time_management__1_" />

What I tried so far is to use the same code as it is working for textviews. Sadly when i set the autosizetype to uniform the text is just getting bigger and not scaling.

   app:autoSizeMaxTextSize="14sp"
        app:autoSizeMinTextSize="4sp"
        app:autoSizeStepGranularity="0.5sp"
        app:autoSizeTextType="uniform"

How it is looking now

1

There are 1 answers

0
Leonardo Sibela On

Automatic sizing is not something you can have out of the box on Chip components just like you have for TextViews.

If you want to achieve such result, you must create a custom view. That way you can measure the text and resize it to fit the container.