Я хочу создать анимацию с двумя действиями. Первое действие: просмотр вперед, второе действие: просмотр назад. Я создаю xml для описания анимации, но он не работает. Спасибо за внимание. Мой /anim/move_animation.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="50%"
android:toYDelta="50%"
android:fromXDelta="0%"
android:toXDelta="50%"
android:duration="2000" />
<translate
android:startOffset="2000"
android:fromYDelta="50%"
android:toYDelta="50%"
android:fromXDelta="50%"
android:toXDelta="0%"
android:duration="2000" />
</set>
Активность:
public class TestActivity extends Activity {
private LinearLayout LL;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LL = (LinearLayout) this.findViewById(R.id.MainLayout);
Animation anim = AnimationUtils.loadAnimation(this, R.anim.move_animation);
LL.startAnimation(anim);
}
}
Макет:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/MainLayout" >
<ImageView
android:id="@+id/Icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/icon" >
</ImageView>
</LinearLayout>