2

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?

Community
  • 1
  • 1
alex2k8
  • 42,496
  • 57
  • 170
  • 221

1 Answers1

5

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.

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156