view动画
来源:互联网 发布:用什么软件转码快 编辑:程序博客网 时间:2024/05/22 00:39
1、View动画属于res/anim/目录,这个xml文件必须有一个很元素,这个根元素可以是<alpha>, <scale>, <translate>, <rotate>中的一种,或者是<set>。
2、默认情况下放在<set>下的动画都是同时执行的,如果想要让其按顺序执行,可以指定 startOffset属性。
<set android:shareInterpolator="false">
<scale
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="1.0"
android:toXScale="1.4"
android:fromYScale="1.0"
android:toYScale="0.6"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false"
android:duration="700" />
<set android:interpolator="@android:anim/decelerate_interpolator">
<scale
android:fromXScale="1.4"
android:toXScale="0.0"
android:fromYScale="0.6"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="400"
android:fillBefore="false" />
<rotate
android:fromDegrees="0"
android:toDegrees="-45"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="400" />
</set>
</set>
ImageView spaceshipImage = (ImageView) findViewById(R.id.spaceshipImage);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
spaceshipImage.startAnimation(hyperspaceJumpAnimation);
3、Some values, such as pivotX, can be specified relative to the object itself or relative to the parent. Be sure to use the proper format for what you want ("50" for 50% relative to the parent, or "50%" for 50% relative to itself).
4、View的四种动画的属性值
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@[package:]anim/interpolator_resource"
android:shareInterpolator=["true" | "false"] >
<alpha
android:fromAlpha="float"
android:toAlpha="float" />
<scale
android:fromXScale="float"
android:toXScale="float"
android:fromYScale="float"
android:toYScale="float"
android:pivotX="float"
android:pivotY="float" />
<translate
android:fromXDelta="float"
android:toXDelta="float"
android:fromYDelta="float"
android:toYDelta="float" />
<rotate
android:fromDegrees="float"
android:toDegrees="float"
android:pivotX="float"
android:pivotY="float" />
<set>
...
</set>
</set>
5、<alpha>动画
android:fromAlpha属性:(开始时的透明度)浮点型数值(0.0代表完全透明,1.0表示完全不透明)
android:toAlpha属性:(结束时的透明度)浮点型数值
6、<scale>动画
A resizing animation. You can specify the center point of the image from which it grows outward (or inward) by specifying pivotX and pivotY. For example, if these values are 0, 0 (top-left corner), all growth will be down and to the right. Represents a ScaleAnimation.
android:fromXScale
Float. Starting X size offset, where 1.0 is no change.
android:toXScale
Float. Ending X size offset, where 1.0 is no change.
android:fromYScale
Float. Starting Y size offset, where 1.0 is no change.
android:toYScale
Float. Ending Y size offset, where 1.0 is no change.
android:pivotX
Float. The X coordinate to remain fixed when the object is scaled.
android:pivotY
Float. The Y coordinate to remain fixed when the object is scaled.
7、<translate>动画
A vertical and/or horizontal motion. Supports the following attributes in any of the following three formats: values from -100 to 100 ending with "%", indicating a percentage relative to itself; values from -100 to 100 ending in "%p", indicating a percentage relative to its parent; a float value with no suffix, indicating an absolute value. Represents a TranslateAnimation.
android:fromXDelta
Float or percentage. Starting X offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element width (such as "5%"), or in percentage relative to the parent width (such as "5%p").
android:toXDelta
Float or percentage. Ending X offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element width (such as "5%"), or in percentage relative to the parent width (such as "5%p").
android:fromYDelta
Float or percentage. Starting Y offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element height (such as "5%"), or in percentage relative to the parent height (such as "5%p").
android:toYDelta
Float or percentage. Ending Y offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element height (such as "5%"), or in percentage relative to the parent height (such as "5%p").
8、<rotate>动画
attributes:
android:fromDegrees
Float. Starting angular position, in degrees.
android:toDegrees
Float. Ending angular position, in degrees.
android:pivotX
Float or percentage. The X coordinate of the center of rotation. Expressed either: in pixels relative to the object's left edge (such as "5"), in percentage relative to the object's left edge (such as"5%"), or in percentage relative to the parent container's left edge (such as "5%p").
android:pivotY
Float or percentage. The Y coordinate of the center of rotation. Expressed either: in pixels relative to the object's top edge (such as "5"), in percentage relative to the object's top edge (such as"5%"), or in percentage relative to the parent container's top edge (such as "5%p").
网址:http://developer.android.com/guide/topics/resources/animation-resource.html
- view 动画
- view动画
- View动画
- view 动画
- View动画
- View动画
- View动画
- view动画、block动画
- View动画、Drawable动画
- Android动画-View动画
- Android动画二:View动画
- Android动画之------View动画
- Android动画-View动画,插值器
- Android动画之View动画
- View动画、帧动画、属性动画
- View动画、Drawable动画、Property动画介绍
- 动画之基础动画(view动画)
- iPhone View切换动画
- 三、从C到C++(三)内联函数、内联函数的处理和限制、C++中新的类型转换符
- mysql 启动方式
- Android Handler的使用
- 集群(高并发)概念
- USB2.0速度识别
- view动画
- 目前公司产品架构
- Nginx源码学习资源集
- windows进程间通信常用方法
- adblockplus for chrome代码编译
- 工艺——使用类进行指针转换
- C++文件在安卓上的转移(以NDK为工具)
- 回溯-八皇后问题
- nyoj-苹果