我正试图为我的Android应用制作启动画面。我找到了许多与这个问题相关的答案。但没有一个正常工作。我只想 1.首先fade_in一个imageView,然后旋转然后fade_out 或2.所有在同一时间。我试过这些代码
final ImageView iv = (ImageView) findViewById(R.id.imageView);
final Animation an = AnimationUtils.loadAnimation(getBaseContext(),R.anim.animate);
iv.startAnimation(an);
an.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
finish();
Intent i = new Intent(getBaseContext(),Welcome.class);
startActivity(i);
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
和动画xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<rotate
android:duration="10000"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="5000"/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="5000"/>
</set>
答案 0 :(得分:0)
你可以使用它来旋转,淡出和淡出,
<?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">
<alpha
android:duration="5000"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatCount="1"
android:repeatMode="reverse"
android:toAlpha="0.4"/>
<rotate
android:duration="10000"
android:fromDegrees="0"
android:interpolator="@android:anim/cycle_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="180"/>
</set>
答案 1 :(得分:0)
您必须指定startOffset
。如果未指定,动画集中的所有元素都将同时启动。试试这个:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="5000" />
<rotate
android:duration="10000"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="5000" />
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="5000"
android:startOffset="15000" />
</set>