mahsa sadeghi
mahsa sadeghi

Reputation: 68

android animation textview rotate string left to right

I need the String inside the textview to be animated from left to right so that when the text is removed from the right, it can be entered from the left, as shown below.

initial state

The text above (Compute Sentence Probability) must be animated as follows and removed from the image and entered on the other side ,as shown below.

animated state

I used the animation below, but in this animation the whole text comes from the right once to the left, and again it does not enter at the same time as the text leaves the other side, and the text does not enter again until the whole text is out.

animation

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
  android:duration="6000"
  android:fromXDelta="100%"
  android:interpolator="@android:anim/linear_interpolator"
  android:repeatCount="infinite"
  android:repeatMode="restart"
  android:toXDelta="-100%" />

Upvotes: 1

Views: 379

Answers (2)

abolfazl bazghandi
abolfazl bazghandi

Reputation: 995

This answer work and if you want support right to left can add below code to TextView in xml

android:textDirection="rtl"

Upvotes: 1

Dinesh
Dinesh

Reputation: 1670

Remove all animation from TextViewand

In your xml file add textview

<TextView
    android:id="@+id/tvUsername"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Computer Sentence Probability..........."
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
 />

In java file simple add this line

TextView tvUsername = (TextView)findViewById(R.id.tvUsername);  
tvUsername.setSelected(true);

Upvotes: 2

Related Questions