Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal scrolling text in Android

I've been looking around for quite some time now, and I can't get a straight answer for my question.

It's quite simple: How can I get a nice scrolling text just like the long app names in the Market when you select an application?

like image 970
greve Avatar asked Oct 05 '10 09:10

greve


2 Answers

I've figured it out by myself.

android:ellipsize="marquee"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
like image 129
greve Avatar answered Oct 05 '22 03:10

greve


Make a translate animation in your anim folder like:

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="12000"
    android:fromXDelta="100"
    android:interpolator="@android:anim/linear_interpolator"
    android:repeatCount="infinite"
    android:repeatMode="restart"
    android:toXDelta="-100" />

And then to your textview like:

yourtextview.startAnimation((Animation)AnimationUtils.loadAnimation(Context,R.anim.youranim_xml));

Hope this might help you.

Edit:

Try this:

<TextView 
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:padding="4dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Simple application that shows how to use marquee, with a long text" />
like image 23
IronBlossom Avatar answered Oct 05 '22 01:10

IronBlossom