Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrolling single line, long text, in TextView

Please have a look at the following simple code.

 <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="John Jonathan Samuwell Abbruzzi"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:textSize="50sp" />

The text in TextView is larger than the width of the screen and should be in single line. I added android:scrollHorizontally="true", so the user can scroll it to see the rest of the text. But, it is not happening. What have I done wrong?

like image 416
PeakGen Avatar asked Mar 21 '23 19:03

PeakGen


1 Answers

Put your textview inside the HorizontalScrollView its working i am tested..

<HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
   <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="John Jonathan Samuwell Abbruzzi"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:textSize="50sp" />
</HorizontalScrollView>
like image 90
kalyan pvs Avatar answered Apr 06 '23 12:04

kalyan pvs