<pre name="code" class="java"> // 动画效果
Animation translate = AnimationUtils.loadAnimation(this,
R.anim.splash_loading);
translate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent intent = new Intent();
intent.setClass(SplashActivity.this, MainActivity.class);
startActivity(intent);
// enterAnim进入动画,exitAnim退出动画
overridePendingTransition(R.anim.push_left_in,
R.anim.push_left_out);
SplashActivity.this.finish();
}
});
mSplashItem.setAnimation(translate);
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="50%" android:toXDelta="0"
android:duration="600" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%"
android:duration="600" />
</set>
<pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fillAfter="true"
android:fromXDelta="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="60%p" />
<!-- accelerate_decelerate_interpolator 加速减速插值 -->