0

enter image description here

I want to scroll a text automatically in horizontal way. I tried the method below, but the text was not scrolling.

   <TextView  
    android:id="@+id/text"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg_1"
    android:textColor="#cc0000"
    android:scrollHorizontally="true"
    android:singleLine="true" 
    android:ellipsize="marquee"
    android:marqueeRepeatLimit ="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true"
   />

So please tell me how to scroll a text and if there is any need to add some code in the class file also.

Adinia
  • 3,722
  • 5
  • 40
  • 58
Ramakrishna
  • 4,066
  • 16
  • 48
  • 72

4 Answers4

1

your TextView don´t scroll because their with must be fill_parent, and the other thing is that the textview must be selected (not pressed) to scroll.

Franco
  • 7,385
  • 3
  • 27
  • 22
  • thanks for giving replay. i replaced width with fill_parent but it didin't scrolling – Ramakrishna Jan 31 '11 at 13:02
  • alraedy i set the text in class file – Ramakrishna Jan 31 '11 at 13:04
  • 1
    TextView wont scroll if isn´t selected, Selected mode don´t work in Touch screen. Check if selecting the TextView with the keyboard pad get the textview scrolls. Also, check this question http://stackoverflow.com/questions/1827751/is-there-a-way-to-make-ellipsize-marquee-always-scroll – Franco Jan 31 '11 at 13:23
0

Try this....

<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>
Sai Aditya
  • 2,353
  • 1
  • 14
  • 16
0

Also, beside what Franco told you, you have set android:ellipsize="marquee"(that truncate the text to fit on that single line you have set), so probably that mix up with the scrolling you set by android:scrollHorizontally="true"
My suggestion is to try to remove the ellipsize property.

Adinia
  • 3,722
  • 5
  • 40
  • 58
0

i put a listview in above textview so the textview is not scrolling. so itried this one

set listview focusable is false

listview.setfocusable(false);

then it works the text was scrolling.

Ramakrishna
  • 4,066
  • 16
  • 48
  • 72