編輯:關於Android編程
本文以實例形式展示了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程序設計有一定的借鑒價值。
android靈活布局
一開始接觸android,只知道拖拉布局,不靈活,難看很。後來才發現,原來和jsp一樣,可以靈活使用xml文件。 話不多說,直接上例子 任何布局既可以在代碼中實現,也可以
Android基礎入門教程——8.2.2 Bitmap引起的OOM問題
Android基礎入門教程——8.2.2 Bitmap引起的OOM問題標簽(空格分隔): Android基礎入門教程本節引言: 上節,我們已經學習
Android仿新浪微博分頁管理界面(3)
本文實例為大家分享了Android仿新浪微博分頁管理界面的具體代碼,供大家參考,具體內容如下多個activity分頁管理,為了方便獲取上下文,采用繼承TabActivit
簡單6步 把安卓機變得和蘋果系統一樣快
眾所周知,Android系統對硬件擁有較高的要求,使用一段時間以後就會出現速度變慢、多任務處理卡頓的現象,其實通過一些小技巧,便能提升設備的運行速度,大家不