Eine XML
Animation set
und translate
und setzen diese XML
Datei in /res/anim
Ordner verwenden. Hier
ist ein Beispiel
//sequestial_move.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator" >
<!-- Use startOffset to give delay between animations -->
<!-- Move -->
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="300"
android:toXDelta="75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="1100"
android:toYDelta="70%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="1900"
android:toXDelta="-75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="2700"
android:toYDelta="-70%p" />
</set>
ANWENDUNG:
laden Animation aus XML
und verwenden Animation .startAnimation(..)
Methode
............
...................
TextView txtMessage = (TextView) findViewById(R.id.txtMessage);
Button btnStart = (Button) findViewById(R.id.btnStart);
// load the animation
Animation animSequestialMove = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.sequestial_move);
// button click event
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
txtMessage.setVisibility(View.VISIBLE);
// start the animation
txtMessage.startAnimation(animSequestialMove);
}
});
.............
.....................
Hier ist eine gute tutorial über verschiedene Arten mit von Animations
.
Hope this helfen ~
perfekt funktioniert brauchen! Hast du irgendwelche Tipps für den Knopf, um nie aufzuhören, sich zu bewegen? – Felipe
Versuchen Sie Folgendes: animSequestialMove.setDuration (10000); animSequestialMove.setRepeatCount (-1); animSequestialMove.setRepeatMode (Animation.REVERSE); animSequestialMove.setInterpolator (neuer LinearInterpolator()); – FAT
Hier ist eine SO-Antwort zum Wiederholen der Animation: http://StackOverflow.com/Questions/7281276/How-to-Move-Image-Up-and-Down-Continuous-Use-Translate-Animation-in-android – FAT