0

I noticed in my app that some of my AutoCompleteTextViews height are being increased whice cause my UI to look weird if the user changes the device text size in the settings.. ive looked into autoSizeTextType and set it to none but it does not solve it and I also use dp as the textsize instead of sp which causes the text to stay in the same size but the view itself get increased height which breaks my UI..

Any suggestions on how to keep the view height fixed and avoid the change caused by device text size changes?

*I half-solved it only when setting the height to explicit dp size e.g 25dp but then text I type inside is not fitting the view and you cant see whats written insde..

my AutoCompleteTextView xml:

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/contactNameTextField"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginTop="5dp"
            android:layout_marginEnd="10dp"
            android:textColorHint="@color/hintColor"
            android:theme="@style/EditTextStyle"
            app:boxBackgroundColor="@color/fragmentBackground"
            app:boxStrokeWidth="3dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="@id/nameText"
            app:layout_constraintTop_toTopOf="@id/nameText">

            <AutoCompleteTextView
                android:id="@+id/itemContactName"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:autoSizeTextType="none"
                android:imeOptions="actionDone"
                android:maxLines="1"
                android:textSize="18dp" />

when increasing the text size in device settings

Yarin Shitrit
  • 297
  • 4
  • 16
  • "I half-solved it only when setting the height to explicit dp size e.g 25dp but then text I type inside is not fitting the view and you cant see whats written insde" - of course it won't. The view resizes itself _to fit the content_. You can set a fixed size on the outer container (depending on how you include this) to get some resizing, but if you have a fixed size, you're eventually gonna fill it up so much that the content exceeds the container. It's an unavoidable fact that also makes this question seem like an XY-problem – Zoe Aug 26 '21 at 09:48

1 Answers1

-1

You can do it by typing <item name="android:textSize">textsize<item/> in your styles.xml or themes.xml. Note that it will change the whole text size of the application. Or if it doesn't work, see this answer. I am sure it will help you.

Spyware
  • 37
  • 8