alex2k8
alex2k8

Reputation: 43214

Multiline TextView without words wrapping on 4.x?

I want to create a TextView that does NOT wrap text, and allow vertical/horizontal scrolling? The solution described here no longer works on 4.0.3.

Is there any solution for 4.x?

Upvotes: 2

Views: 2076

Answers (1)

BlackHatSamurai
BlackHatSamurai

Reputation: 23513

Wrap your text in a HorizontalScrollView for horizontal scrolling:

 <?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/text_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:singleLine="false"
        android:maxLines="3"
        android:scrollbars="vertical"
        android:textColor="@android:color/secondary_text_dark_nodisable"
        >
    </TextView>
</HorizontalScrollView>

For vertical scrolling use ScrollView.

Also, this XML was just grabbed from the answer you referenced.

Upvotes: 5

Related Questions