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

首頁 > 系統 > Android > 正文

Android開啟動畫之漸隱漸現效果

2019-10-21 21:48:12
字體:
來源:轉載
供稿:網友

啟動某項程序時我們往往都能看到不同的“開機動畫”,千變萬化的動畫也只不過是四種基本動畫衍變美化而成的。

四種android動畫效果:

  • alpha         漸變透明度動畫效果
  • scale         漸變尺寸伸縮動畫效果
  •  translate  畫面轉換位置移動動畫效果
  • rotate        畫面轉移旋轉動畫效果

最簡單的莫過于漸變透明效果,單單這一種就可完成漸隱漸現的動畫效果(用于漸現漸隱的可以是整個歡迎頁面也可以是歡迎頁面里的一部分):

1)、 在res里新建anim文件夾用來盛放動畫定義的動作文件:

<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/accelerate_interpolator">    <alpha       android:fromAlpha="0.0"      android:toAlpha="1.0"      android:duration="2000"/>    <alpha       android:fromAlpha="1.0"      android:toAlpha="0.0"      android:startOffset="3000"      android:duration="3000"/>  </set>

fromalpha即開始的透明度,toalpha即結束時的透明度,duration為時間(單位毫秒)。

2)、定義布局文件(layout):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:gravity="center_vertical|center_horizontal"  android:orientation="vertical" >   <ImageView    android:id="@+id/welcom_logo"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:src="@drawable/welcome" /> </LinearLayout>

這里和以往沒有任何不同,只需對要漸現漸隱的圖片進行id標示。

3)、實現方法(Activity):

public class WelcomeActivity extends Activity implements AnimationListener { private ImageView imageView = null; private Animation alphaAnimation = null;  @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); imageView = (ImageView) findViewById(R.id.welcom_logo); alphaAnimation = AnimationUtils.loadAnimation(this,  R.anim.welcome_alpha); alphaAnimation.setFillEnabled(true);//啟動Fill保持 alphaAnimation.setFillAfter(true);//設置動畫的最后一幀是保留在view上的 imageView.setAnimation(alphaAnimation); alphaAnimation.setAnimationListener(this);  }  @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_welcome, menu); return true; }  @Override public void onAnimationEnd(Animation animation) { //動畫結束時結束歡迎頁面并跳轉到主頁面 Intent intent=new Intent(this,GroupActivity.class); startActivity(intent); this.finish();  }  @Override public void onAnimationRepeat(Animation animation) {   }  @Override public void onAnimationStart(Animation animation) {   } public boolean onKeyDown(int KeyCode,KeyEvent event){ //在歡迎頁面屏蔽BACK鍵 if(KeyCode==KeyEvent.KEYCODE_BACK){  return false; } return false;  }}

歡迎頁面顧名思義只是裝飾作用一閃而過不需要返回鍵進行操作。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 利辛县| 马尔康县| 西丰县| 岢岚县| 淳安县| 奉节县| 浦东新区| 阿图什市| 如东县| 镇江市| 中江县| 青浦区| 安西县| 普兰县| 民和| 文成县| 丹棱县| 宁明县| 兰考县| 高平市| 墨竹工卡县| 泾川县| 清苑县| 徐水县| 柳河县| 定远县| 肥乡县| 青川县| 阿拉善左旗| 确山县| 项城市| 明水县| 永济市| 个旧市| 亳州市| 平舆县| 微山县| 徐闻县| 福泉市| 将乐县| 二手房|