android啟動漸變效果,左至右消失
阿新 • • 發佈:2019-02-16
<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 加速減速插值 -->