Reputation: 34497
Hi I am using autosize textview in my android application. My app minSdkVersion is 19 so I am using support library.
https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview.html
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.app.android.registration.RegistrationActivity"
tools:ignore="missingPrefix">
<include
android:id="@+id/toolbar_registration_layout"
layout="@layout/toolbar" />
<TextView
android:id="@+id/textview_registration_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/lato_medium"
android:padding="8dp"
android:text="@string/registration_title"
app:autoSizeTextType="uniform"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
</android.support.constraint.ConstraintLayout>
Does anyone know why it is not resizing as there is lot of space available on right side of it.
Upvotes: 6
Views: 9809
Reputation: 969
In my case using only fixed dimension or match_parent didn't work. I had to add "maxLines=1" and "lines=1". Don't know why is this not made obvious in the documentation.
Upvotes: 13
Reputation: 2847
Change your android:layout_height="wrap_content"
to a specific value
Like : android:layout_height="200dp"
You can read in documentation -:
Note: If you set autosizing in an XML file, it is not recommended to use the value "wrap_content
" for the layout_width
or layout_height
attributes of a TextView
. It may produce unexpected results.
So, you must pass a fixed value to android:layout_height
of TextView
Hope, this will help you
Upvotes: 17