简体   繁体   中英

Android slide animation

Why I am not able to slide text view in android from right to left continuously?

I am using below xml:

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

    <translate
        android:fromXDelta="-3%p"
        android:toXDelta="3%p"
        android:duration="1200" />
</set>

If you want your animation to play continuously, you need to add the following two attributes to "translate" tag.

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">

    <translate
        android:fromXDelta="-3%p"
        android:toXDelta="3%p"
        android:duration="1200"
        android:repeatCount="infinite"
        android:repeatMode="reverse"/>
</set>

Note that if “repeatCount" and "repeatMode" are added to "set" tag, things will not work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM