android图片跳转动画效果,Android实现Activity界面切换添加动画特效的方法
本文以實(shí)例形式展示了Android實(shí)現(xiàn)Activity界面切換添加動(dòng)畫特效的方法,對(duì)于Android程序設(shè)計(jì)人員來(lái)說(shuō)有很好的參考借鑒價(jià)值。具體方法如下:
了解Android程序設(shè)計(jì)的人應(yīng)該知道,在Android 2.0之后有了overridePendingTransition(),其中里面兩個(gè)參數(shù),一個(gè)是前一個(gè)activity的退出,另一個(gè)activity的進(jìn)入。
現(xiàn)看看下面這段示例代碼:
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);
這可沒(méi)有上個(gè)好但是也可以 。
實(shí)現(xiàn)淡入淡出的效果:
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);
實(shí)現(xiàn)zoomin和zoomout,即類似iphone的進(jìn)入和退出時(shí)的效果:
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"/>
相信本文所述示例對(duì)大家的Android程序設(shè)計(jì)有一定的借鑒價(jià)值。
您可能感興趣的文章:
總結(jié)
以上是生活随笔為你收集整理的android图片跳转动画效果,Android实现Activity界面切换添加动画特效的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 华为Android9.0谷歌框架,华为M
- 下一篇: 小米6 android os,脱离安卓!