a.p.
a.p.

Reputation: 3288

Keeping Textview content on 1 line and prevent wrapping

I would like to have a text displayed on an Android widget (remote views) not wrap over its text to the next line, if the text is longer than the Textview's width. Instead of that, I would like to have the Textview cut any extra text. I have tried many things without success.

Here is the XML code for the TextView:

    <TextView
        android:id="@+id/txtInformation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:maxWidth="220dp"
        android:lines="1"
        android:text="Long text long text long text long text"
        android:textSize="13sp" />

Upvotes: 6

Views: 5438

Answers (1)

Karakuri
Karakuri

Reputation: 38595

In your layout XML, use android:maxLines="1" or android:singleLine="true"

Upvotes: 11

Related Questions