国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android實現Activity界面切換添加動畫特效的方法

2020-04-11 11:45:01
字體:
來源:轉載
供稿:網友

本文以實例形式展示了Android實現Activity界面切換添加動畫特效的方法,對于Android程序設計人員來說有很好的參考借鑒價值。具體方法如下:

了解Android程序設計的人應該知道,在Android 2.0之后有了overridePendingTransition(),其中里面兩個參數,一個是前一個activity的退出,另一個activity的進入。

現看看下面這段示例代碼:

@Override  public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.SplashScreen);     new Handler().postDelayed(new Runnable() {      @Override      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);  }  

上面的代碼只是閃屏的一部分。

getWindow().setWindowAnimations(int);  

這可沒有上個好但是也可以 。

實現淡入淡出的效果:

overridePendingTransition(Android.R.anim.fade_in,android.R.anim.fade_out);  

由左向右滑入的效果:

overridePendingTransition(Android.R.anim.slide_in_left,android.R.anim.slide_out_right);  

實現zoomin和zoomout,即類似iphone的進入和退出時的效果:

overridePendingTransition(R.anim.zoomin, R.anim.zoomout);  

新建zoomin.xml文件:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:Android="http://schemas.android.com/apk/res/android"     Android:interpolator="@android:anim/decelerate_interpolator">   <scale Android:fromXScale="2.0" android:toXScale="1.0"       Android:fromYScale="2.0" android:toYScale="1.0"       Android:pivotX="50%p" android:pivotY="50%p"       Android:duration="@android:integer/config_mediumAnimTime" /> </set> 

新建zoomout.xml文件:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:Android="http://schemas.android.com/apk/res/android"     Android:interpolator="@android:anim/decelerate_interpolator"     Android:zAdjustment="top">   <scale Android:fromXScale="1.0" android:toXScale=".5"       Android:fromYScale="1.0" android:toYScale=".5"       Android:pivotX="50%p" android:pivotY="50%p"       Android:duration="@android:integer/config_mediumAnimTime" />   <alpha Android:fromAlpha="1.0" android:toAlpha="0"       Android:duration="@android:integer/config_mediumAnimTime"/> </set>  

相信本文所述示例對大家的Android程序設計有一定的借鑒價值。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 当雄县| 库伦旗| 大同县| 连城县| 贵阳市| 广汉市| 阿图什市| 遂溪县| 佛坪县| 巴彦淖尔市| 四川省| 吉首市| 桂林市| 威海市| 赣州市| 芮城县| 临猗县| 皋兰县| 剑川县| 来凤县| 宽甸| 菏泽市| 若羌县| 监利县| 汽车| 烟台市| 灵山县| 清远市| 太康县| 嘉禾县| 巢湖市| 梁山县| 满城县| 曲水县| 合肥市| 定结县| 江口县| 仁化县| 德州市| 繁峙县| 富平县|