Reputation: 10148
In my application,i have text view with long text. i need text wrapping like in the android emulator->contact->phone (screen short of dialpad in contact).
but in my application i get text wrapping as follows in the figure:
i have tried several ways it does not meet my requirement. i do not need the "..." at right corner of the text view. instead of that, i want to wrap the text as in the first figure(android emulator->contact->phone). how to do that? please help me. Thanks in advance.
Upvotes: 6
Views: 15873
Reputation: 666
Android Studio 3.5
All you need to do is set an End constraint in a constraintlayout inside your textView:
app:layout_constraintEnd_toEndOf="parent"
Upvotes: 0
Reputation: 5371
Alternatively, you can use support library's autosizing for TextViews
as per the Android docs.
How to use?
For API 26 and later:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:autoSizeTextType="uniform" />
To support earlier version of Android you can use:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
app:autoSizeTextType="uniform" />
If you have an option that increases/decreases TextView
size then you can do:
For API 26 and later:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="12sp"
android:autoSizeMaxTextSize="100sp"
android:autoSizeStepGranularity="2sp" />
For earlier versions:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="12sp"
app:autoSizeMaxTextSize="100sp"
app:autoSizeStepGranularity="2sp" />
Upvotes: 1
Reputation: 68177
I think setting the following properties to your TextView should help you to achieve this behavior:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:singleLine="false"
Upvotes: 8