动画:水平和垂直移动ImageButton
问题描述:
我的ImageButton正在水平移动。但我想移动水平和垂直。 然后重复。动画:水平和垂直移动ImageButton
move.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:fillBefore="true"
android:repeatMode="reset">
<translate
android:fromXDelta="0%p"
android:toXDelta="70%p"
android:duration="2000" />
</set>
hand_motion.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aa000000"
android:id="@+id/VHandLevel">
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/ibtnHandLevel"
android:background="@drawable/hand1"
android:layout_marginTop="80dp" />
</RelativeLayout>
如果我加入这一行中move.xml:
android:toYDelta="70%p"
将角移动。但我想先水平移动然后垂直也会重复。
MainActivity.java的一些代码
答
如果要创建动画的实例程序是这样的:
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
那么你可以设置柜台重复相同动画多次 只要你想:
animation.setRepeatCount(10);