Horizontal scroll on textview on android?

Just use this

   textview.setMovementMethod(new ScrollingMovementMethod());
   textview.setHorizontallyScrolling(true);

I'm a bit late but I managed to achieve same result without adding the HorizontalScrollView

EditText extends TextView to support scrolling and selection. So, you can use the EditText as a TextView (touch, focus and cursor are disabled).

<EditText
    android:id="@+id/edit_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent" --> This remove that line at the bottom
    android:clickable="false" --> It can be true if you need to handle click events
    android:cursorVisible="false" --> Hide the cursor
    android:focusable="false" --> Disable focus
    android:singleLine="true"
    android:text="This is a very long text that won't be possible to display in a single line"/>

I'm just not able to test in a wide range of devices... I'm just sharing because it may be useful to someone else.


<HorizontalScrollView android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="40dp"
        android:layout_height="wrap_content"
        android:scrollHorizontally="true"
        android:text="Horizontal scroll view will work now"/>

</HorizontalScrollView>

This is how you can make textview scroll horizontally.

Tags:

Java

Android