from:http://www.open-open.com/lib/view/open1326371644030.html
注意,原始文章zhong
| java.lang.Object | |||||
| ↳ | android.view.View | ||||
| ↳ | android.view.ViewGroup | ||||
| ↳ | android.widget.FrameLayout | ||||
| ↳ | android.widget.ViewAnimator | ||||
| ↳ | android.widget.ViewFlipper | ||||
Class Overview
Simple ViewAnimator that 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.
该类有如下几个和动画相关的函数:
setInAnimation:设置View进入屏幕时候使用的动画,该函数有两个版本,一个接受单个参数,类型为android.view.animation.Animation;一个接受两个参数,类型为Context和int,分别为Context对象和定义Animation的resourceID。
setOutAnimation: 设置View退出屏幕时候使用的动画,参数setInAnimation函数一样。
showNext: 调用该函数来显示FrameLayout里面的下一个View。
showPrevious: 调用该函数来显示FrameLayout里面的上一个View。
3、首选看一下定义四个动画的xml文件:
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http:///apk/res/android" >
- <translate
- android:duration="3000"
- android:fromXDelta="-100%p"
- android:toXDelta="0" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http:///apk/res/android" >
- <translate
- android:duration="3000"
- android:fromXDelta="0"
- android:toXDelta="100%p" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http:///apk/res/android" >
- <translate
- android:duration="3000"
- android:fromXDelta="100%p"
- android:toXDelta="0" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http:///apk/res/android" >
- <translate
- android:duration="3000"
- android:fromXDelta="0"
- android:toXDelta="-100%p" />
- </set>
















