Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Google Play like TextView animation when text is too long?

In Google Play when the name of a certain title is too long then they apply an animation on this TextView when the name is going out from one end of the TextView, goes in from the other end, stops for a second on the beginning of the Title text, and then goes for the next round.

Does anyone have any explanation how can this be achieved?

like image 868
Emil Adz Avatar asked Oct 20 '25 16:10

Emil Adz


2 Answers

This was what worked for me, you have to actually request for focus in order for the marquee animation to work:

  <TextView
        android:id="@+id/tvAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tvName"
        android:layout_toLeftOf="@+id/ivLogo"
        android:text=""
        android:textColor="@color/cups_white"
        android:textSize="18sp" 
        android:ellipsize="marquee"
        android:singleLine="true"
        android:marqueeRepeatLimit ="marquee_forever"
        android:scrollHorizontally="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:duplicateParentState="true">
        <requestFocus 
          android:focusable="true" 
          android:focusableInTouchMode="true"
          android:duplicateParentState="true" />
    </TextView>
like image 199
Emil Adz Avatar answered Oct 23 '25 05:10

Emil Adz


In your xml file where the TextView is declared you can use the following attributes:

android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"

with the singleline you going sure thats the Text is showend only in one line.

For more details look at this: http://developer.android.com/reference/android/widget/TextView.html

like image 27
Manu Zi Avatar answered Oct 23 '25 06:10

Manu Zi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!