android图片跳转动画效果,Android实现Activity界面切换添加动画特效的方法
本文以實例形式展示了Android實現Activity界面切換添加動畫特效的方法,對于Android程序設計人員來說有很好的參考借鑒價值。具體方法如下:
了解Android程序設計的人應該知道,在Android 2.0之后有了overridePendingTransition(),其中里面兩個參數,一個是前一個activity的退出,另一個activity的進入。
現看看下面這段示例代碼:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.SplashScreen);
new Handler().postDelayed(new Runnable() {
public void run() {
Intent mainIntent =new Intent(SplashScreen.this,?? AndroidNews.class);
SplashScreen.this.startActivity(mainIntent);
SplashScreen.this.finish();
overridePendingTransition(R.anim.mainfadein,
R.anim.splashfadeout);
}
},3000);
}
上面的代碼只是閃屏的一部分。
1
getWindow().setWindowAnimations(int);
這可沒有上個好但是也可以 。
實現淡入淡出的效果:
1
overridePendingTransition(Android.R.anim.fade_in,android.R.anim.fade_out);
由左向右滑入的效果:
1
overridePendingTransition(Android.R.anim.slide_in_left,android.R.anim.slide_out_right);
實現zoomin和zoomout,即類似iphone的進入和退出時的效果:
1
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
新建zoomin.xml文件:
1
2
3
4
5
6
7
8
Android:interpolator="@android:anim/decelerate_interpolator">
Android:fromYScale="2.0" android:toYScale="1.0"
Android:pivotX="50%p" android:pivotY="50%p"
Android:duration="@android:integer/config_mediumAnimTime" />
新建zoomout.xml文件:
1
2
3
4
5
6
7
8
9
10
11
Android:interpolator="@android:anim/decelerate_interpolator"
Android:zAdjustment="top">
Android:fromYScale="1.0" android:toYScale=".5"
Android:pivotX="50%p" android:pivotY="50%p"
Android:duration="@android:integer/config_mediumAnimTime" />
Android:duration="@android:integer/config_mediumAnimTime"/>
相信本文所述示例對大家的Android程序設計有一定的借鑒價值。
您可能感興趣的文章:
總結
以上是生活随笔為你收集整理的android图片跳转动画效果,Android实现Activity界面切换添加动画特效的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为Android9.0谷歌框架,华为M
- 下一篇: 小米6 android os,脱离安卓!