from:http://www.open-open.com/lib/view/open1326371644030.html

注意,原始文章zhong

1、屏幕切换指的是在同一个Activity内屏幕见的切换,最长见的情况就是在一个FrameLayout内有多个页面,比如一个系统设置页面;一个个性化设置页面。 2、介绍ViewFilpper类

ViewFlipper

extendsViewAnimator
java.lang.Object
android.view.View

android.view.ViewGroup


android.widget.FrameLayout



android.widget.ViewAnimator




android.widget.ViewFlipper

Class Overview

SimpleViewAnimatorthat will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.

意思是:简单的ViewAnimator之间,两个或两个以上的view加上动画效果。只有一个小孩会显示在一个时间。如果需要,每个孩子能自动翻转之间在固定的时间间隔。

该类继承了Framelayout类,ViewAnimator类的作用是为FrameLayout里面的View切换提供动画效果。

该类有如下几个和动画相关的函数:

setInAnimation:设置View进入屏幕时候使用的动画,该函数有两个版本,一个接受单个参数,类型为android.view.animation.Animation;一个接受两个参数,类型为Context和int,分别为Context对象和定义Animation的resourceID。

setOutAnimation: 设置View退出屏幕时候使用的动画,参数setInAnimation函数一样。

showNext: 调用该函数来显示FrameLayout里面的下一个View。

showPrevious: 调用该函数来显示FrameLayout里面的上一个View。

3、首选看一下定义四个动画的xml文件: in_leftright.xml——从左到右进入屏幕
                    
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:duration="3000"
  5. android:fromXDelta="-100%p"
  6. android:toXDelta="0"/>
  7. </set>
out_leftright.xml——从左到右出去屏幕
                    
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:duration="3000"
  5. android:fromXDelta="0"
  6. android:toXDelta="100%p"/>
  7. </set>
in_rightleft.xml——从右到左进入屏幕
                    
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:duration="3000"
  5. android:fromXDelta="100%p"
  6. android:toXDelta="0"/>
  7. </set>
out_rightleft.xml——从右到左出去屏幕
                    
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:duration="3000"
  5. android:fromXDelta="0"
  6. android:toXDelta="-100%p"/>
  7. </set>

更多相关文章

  1. android 给动画添加结束监听事件
  2. Android(安卓)GUI系统学习1:Gralloc
  3. Android之通过ContentProvider实现两个app(进程间)间通信以及函
  4. Ubuntu下Android(安卓)JNI初步学习之——搭建相关环境和测试Demo
  5. Android(安卓)SO逆向-流程控制语句及表达式运算
  6. [qualcomm android] sim card status processing
  7. android小记之Animation4种动画效果(贴上了GIF图)
  8. 【Android动画九章】-AlphaAnimation(渐变动画)
  9. Android后台推送摄像头/屏幕数据

随机推荐

  1. 安装android studio之后无法直接打开SDK
  2. android 開發常用的工具整理(整理中)
  3. 003.android资源文件剖析(Resources)
  4. Android(安卓)画图 之 Matrix(二)
  5. 5.4 Android(安卓)的上下文菜单: Context
  6. Unity3d Free【IOS Android(安卓)WP8 Xbo
  7. 第1章 Android简介与开发环境的配置
  8. 05Android(安卓)Studio使用插件推荐
  9. android 从相册中获取图片设置成头像的问
  10. Android外置存储备忘