成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Android ApiDemo示例解讀3:App->Activity->Animation

移動(dòng)開發(fā) Android
SDK中的示例程序App->Activity->Animation演示了切換Activity時(shí)的動(dòng)畫效果。提供了兩種動(dòng)畫效果,一種是Fade In漸變,后出現(xiàn)的Activity由淺入深逐漸顯示;另一種是Zoom放大效果,后出現(xiàn)的Activity由小及大逐漸顯示。

SDK中的示例程序App->Activity->Animation演示了切換Activity時(shí)的動(dòng)畫效果。提供了兩種動(dòng)畫效果,一種是Fade In漸變,后出現(xiàn)的Activity由淺入深逐漸顯示;另一種是Zoom放大效果,后出現(xiàn)的Activity由小及大逐漸顯示。

Android 中 Animation 資源可以分為兩種:

Tween Animation 對(duì)單個(gè)圖像進(jìn)行各種變換(縮放,平移,旋轉(zhuǎn)等)來實(shí)現(xiàn)動(dòng)畫。

Frame Animation 由一組圖像順序顯示顯示動(dòng)畫。

Animation 中使用的是Tween Animation,使用的資源為R.anim.fade、R.anim.hold、R.anim.zoom_enter、R.anim.zoom_exit。

其中R.anim.fade、R.anim.zoom_enter分別為Fade In 和 Zoom動(dòng)畫資源。其定義為:

fade.xml

  1. <alpha xmlns:android=”http://schemas.android.com/apk/res/android”    
  2. android:interpolator=”@android:anim/accelerate_interpolator”    
  3. android:fromAlpha=”0.0″ android:toAlpha=”1.0″    
  4. android:duration=”@android:integer/config_longAnimTime” />   

zoom_center.xml

  1. <set xmlns:android=”http://schemas.android.com/apk/res/android”    
  2. android:interpolator=”@android:anim/decelerate_interpolator”>   
  3. <scale android:fromXScale=”2.0″ android:toXScale=”1.0″    
  4.  android:fromYScale=”2.0″ android:toYScale=”1.0″    
  5.  android:pivotX=”50%p” android:pivotY=”50%p”    
  6.  android:duration=”@android:integer/config_mediumAnimTime” />   
  7. </set>   

tween animation 資源定義的格式如下:

  1. <?xml version=”1.0″ encoding=”utf-8″?>   
  2.  <set xmlns:android=”http://schemas.android.com/apk/res/android”    
  3.  android:interpolator=”@[package:]anim/interpolator_resource”    
  4.  android:shareInterpolator=[ ” true ” false “>   
  5.  <alpha   
  6.  android:fromAlpha=”float”    
  7.  android:toAlpha=”float” />   
  8.  <scale   
  9.  android:fromXScale=”float”    
  10.  android:toXScale=”float”    
  11.  android:fromYScale=”float”    
  12.  android:toYScale=”float”    
  13.  android:pivotX=”float”    
  14.  android:pivotY=”float” />   
  15.  <translate   
  16.  android:fromXDelta=”float”    
  17.  android:toXDelta=”float”    
  18.  android:fromYDelta=”float”    
  19.  android:toYDelta=”float” />   
  20.  <rotate   
  21.  android:fromDegrees=”float”    
  22.  android:toDegrees=”float”    
  23.  android:pivotX=”float”    
  24.  android:pivotY=”float” />   
  25.  <set> …    
  26.  </set>   
  27.  </set>   

<set> 為其它animation類型<alpha>,<scale>,<translate>和<rotate>或其它<set>的容器。

android:interpolator 為Interpolator資源ID,Interpolator定義了動(dòng)畫的變化速率,動(dòng)畫的各幀的顯示可以加速,減速,重復(fù)顯示。

android:shareInterpolator 如果想為<set>中的各個(gè)子動(dòng)畫定義共享interpolator,shareInterpolator 則設(shè)為true。

<alpha> 定義Fade in 、Fade out 動(dòng)畫,其對(duì)應(yīng)的Android類AlphaAnimation,參數(shù)由fromAlpha,toAlpha定義。

<scale>定義縮放動(dòng)畫,其對(duì)應(yīng)的Android類為ScaleAnimation,參數(shù)由fromXScale、toXScale、 fromYScale、toYScale、pivotX、pivotY定義,pivotX、pivotY定義了縮放時(shí)的中心。

<translate>定義平移動(dòng)畫,其對(duì)應(yīng)的Android類為TranslateAnimation,參數(shù)由fromXDelta、toXDelta、fromYDelta、toYDelta定義。

<rotate>定義選擇動(dòng)畫,其對(duì)應(yīng)的Android類RotateAnimation,參數(shù)由fromDegrees、toDegrees、pivotX、pivotY, pivotX、pivotY定義選擇中心。

Animation中的Fade In和Zoom In按鈕的事件處理代碼:

  1. private OnClickListener mFadeListener = new OnClickListener() {    
  2.  public void onClick(View v) {    
  3.  // Request the next activity transition (here starting a new one).    
  4.  startActivity(new Intent(Animation.this, Controls1.class));    
  5.  // Supply a custom animation.  This one will just fade the new    
  6.  // activity on top.  Note that we need to also supply an animation    
  7.  // (here just doing nothing for the same amount of time) for the    
  8.  // old activity to prevent it from going away too soon.    
  9.  overridePendingTransition(R.anim.fade, R.anim.hold);    
  10.  }    
  11. };   
  12. private OnClickListener mZoomListener = new OnClickListener() {    
  13.  public void onClick(View v) {    
  14.  // Request the next activity transition (here starting a new one).    
  15.  startActivity(new Intent(Animation.this, Controls1.class));    
  16.  // This is a more complicated animation, involving transformations    
  17.  // on both this (exit) and the new (enter) activity.  Note how for    
  18.  // the duration of the animation we force the exiting activity    
  19.  // to be Z-ordered on top (even though it really isn't) to achieve    
  20.  // the effect we want.    
  21.  overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);    
  22.  }    
  23. };   

從代碼可以看到Activity Animation到其它Activity Controls1 切換的動(dòng)畫使用overridePendingTransition 來定義,函數(shù)overridePendingTransition(int enterAnim, int exitAnim) 必須定義在StartActivity(Intent) 或是 Activity.finish()之后來定義兩個(gè)Activity切換時(shí)的動(dòng)畫,enterAnim 為新Activity出現(xiàn)時(shí)動(dòng)畫效果,exitAnim則定義了當(dāng)前Activity退出時(shí)動(dòng)畫效果。

責(zé)任編輯:閆佳明 來源: jizhuomi
相關(guān)推薦

2013-12-19 14:28:04

Android ApiAndroid開發(fā)Android SDK

2013-12-19 14:32:31

Android ApiAndroid開發(fā)Android SDK

2013-12-19 14:13:16

Android ApiAndroid開發(fā)Android SDK

2013-12-19 14:16:46

Android ApiAndroid開發(fā)Android SDK

2013-12-19 14:34:52

Android ApiAndroid開發(fā)Android SDK

2013-12-19 14:36:43

Android ApiAndroid開發(fā)Android SDK

2013-12-19 13:40:44

Android ApiAndroid開發(fā)Android SDK

2013-12-19 13:51:12

Android ApiAndroid開發(fā)Android SDK

2013-12-19 16:26:29

Android ApiAndroid開發(fā)Android SDK

2010-02-02 14:22:50

Python示例

2010-02-01 11:22:09

C++虛函數(shù)

2010-01-28 13:12:47

Android使用An

2019-07-19 10:44:34

移動(dòng)應(yīng)用APP

2014-05-27 14:16:08

AndroidActivitysingleTask

2010-03-02 14:41:00

WCF行為控制

2010-03-05 10:47:05

Python futu

2010-02-04 16:07:39

C++回調(diào)函數(shù)

2010-01-04 17:03:27

Silverlight

2013-01-08 13:33:07

Android開發(fā)Activity入門指南

2010-01-08 10:48:05

VB.NET多線程
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 亚洲精品一二区 | 久久国产日韩 | 中国美女一级黄色片 | 国产高清在线 | 国产精品久久久久久久久久久久冷 | 精品视频在线免费观看 | 免费啪啪| 国产一区二区三区在线视频 | 51ⅴ精品国产91久久久久久 | 一二三四在线视频观看社区 | 国产成人影院 | 天天操夜夜骑 | 欧美福利视频一区 | 密室大逃脱第六季大神版在线观看 | 亚洲午夜精品一区二区三区他趣 | 欧美 中文字幕 | 凹凸日日摸日日碰夜夜 | 天天躁日日躁性色aⅴ电影 免费在线观看成年人视频 国产欧美精品 | 亚洲精品国产第一综合99久久 | 99亚洲 | 日韩中文字幕一区二区 | 欧美一区二区三区 | 一区二区三区不卡视频 | 国产综合视频 | 99re在线视频| 日本久草视频 | 国产精品久久久久aaaa九色 | 激情欧美一区二区三区中文字幕 | 一区二区三区在线 | 亚洲久久一区 | 中文字幕久久久 | 国产美女精品视频免费观看 | www.亚洲一区二区三区 | 午夜婷婷激情 | 亚洲综合无码一区二区 | 蜜桃一区二区三区在线 | 一区二区三区在线 | 亚洲欧美日韩在线 | www日韩| 天天天天操 | 国户精品久久久久久久久久久不卡 |