简介

视图动画,主要包括位移,透明度,旋转和缩放,View本身的属性并没有发生变化,只是在这个视图上添加一些渐变的效果,所以总体而言,视图动画只能实现一些简单的动画效果,属性动画功能更强大。

使用

res/anim目录下创建动画资源文件,存放帧动画和渐变动画,主要tag:

set, alpha, scale, tranlate, rotate分别对应动画集合,透明动画,缩放动画,位移动画,旋转动画

格式

<?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"] >//子元素是否共享这个插值器 <!--[0.0 , 1.0] -->
<alpha
android:fromAlpha="float"
android:toAlpha="float" /> <!--[0.0, ?]
<!-- pivotX,pivotY用来控制缩放的中心点-->
<scale
android:fromXScale="float"
android:toXScale="float"
android:fromYScale="float"
android:toYScale="float"
android:pivotX="float"
android:pivotY="float" /> <!-- 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")-->
<translate
android:fromXDelta="float"
android:toXDelta="float"
android:fromYDelta="float"
android:toYDelta="float" /> <!-- android:pivotX, android:pivotY ---- n 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") -->
<rotate
android:fromDegrees="float"
android:toDegrees="float"
android:pivotX="float"
android:pivotY="float" />
<set>
...
</set>
</set>

< scale >

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="2000"//时常(运行代码不要在这里做注释)
android:pivotX="50%"
android:pivotY="50%"//缩放中心点为视图的中心
android:fromXScale="1.0"//起点大小
android:fromYScale="1.0"
android:toXScale="2.0"//目标大小
android:toYScale="2.0" />
</set>

< alpha>

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="2000"//时常
android:fromAlpha="1.0"//起始透明度
android:interpolator="@android:anim/accelerate_decelerate_interpolator"//插值
android:toAlpha="0.0" />//目标透明度
</set>

< rotate>

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="2000"//时常
android:fromDegrees="0"//起始角度
android:interpolator="@android:anim/decelerate_interpolator"//插值
android:pivotX="50%"
android:pivotY="50%"//旋转中心点为视图中心
android:toDegrees="180" />//目标角度
</set>

< translate>

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="2000"//时常
android:fromXDelta="0"
android:fromYDelta="0"//起始位置相对于视图的位移
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="300"
android:toYDelta="300" />//目标位置相对于视图的位移
</set>

< set>

将上面的代码各种渐变动画全部防止在< set >tag下,实现共同效果

备注

代码中加载动画,例如旋转动画:

rotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_anim);
imageView.startAnimation(rotateAnim);

<Android 基础(二十五)> View Animation的更多相关文章

  1. 浅谈Android样式开发之View Animation (视图动画)

    引言 一个用户体验良好的App肯定少不了动画效果.Android为我们提供了2种动画框架,分别是视图动画(View Animation)和属性动画(Property Animation).视图动画比较 ...

  2. 动画的使用—View Animation

    View Animation定义了下面的四种动画效果: 缩放(scale).位移(translation).旋转(rotation).透明(alpha)   缩放动画: ScaleAnimation( ...

  3. view animation

    动画分为 帧动画    drawable animation 补间动画 view animation 属性动画  property animation 作用效果: 加载信息时loading动画 act ...

  4. Android Animation学习(六) View Animation介绍

    Android Animation学习(六) View Animation介绍 View Animation View animation系统可以用来执行View上的Tween animation和F ...

  5. Android动画View Animation

    Animations 一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等, ...

  6. Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation

    程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...

  7. Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)

    1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...

  8. Android动画之二:View Animation

    作为一个博客<Android其中的动画:Drawable Animation>.android动画主要分为三大部分.上一篇博客已经解说Drawable Animation的使用方法,即逐帧 ...

  9. Android动画三部曲之中的一个 View Animation &amp; LayoutAnimation

    转载请注明出处:http://blog.csdn.net/crazy1235/article/details/50612827 本篇文章对android的Tween动画和帧动画以及布局动画进行总结. ...

  10. android.view.animation(2) - 插值器Interpolator

    public interface Interpolator implements TimeInterpolator android.view.animation.Interpolator Known ...

随机推荐

  1. git 忽略某些文件的命令

    正常的,我们在提交项目版本的时候,经常会存在一些需要忽略的文件或者文件夹,那这个时候,我们就可以通过git的一些操作命令来实现! vim .gitignore 通过上面一句话进入编辑忽略文件/文件夹的 ...

  2. 【BZOJ2732】【HNOI2012】射箭 二分+半平面交

    此题重点在卡精度!!! 本地已经下载数据测试并通过了,然而$B$站上还是$WA$的,可能是$CPU$对于$long\ double$ 的资瓷不一样. 此题答案显然是可以二分出来的,设当前要监测是否能射 ...

  3. python获取动态网站上面的动态加载的数据(selenium+Firefox)

    最近突然想到以前爬取百度学术上的参考文献,大家可以看一下以前我的写的博客:http://www.cnblogs.com/ybf-yyj/p/7351493.html,但是如果利用这个方法,太痛苦了,需 ...

  4. Intellij-怎么避免import.*包,以及import包顺序问题

    Intellij版本 IntelliJ IDEA 2018.1.2 (Ultimate Edition) Build #IU-181.4668.68, built on April 24, 2018 ...

  5. 2017年Android百大框架排行榜

    框架:提供一定能力的小段程序 >随意转载,标注作者"金诚"即可 >本文已授权微信公众号:鸿洋(hongyangAndroid)原创首发. >本文已经开源到Gith ...

  6. safari input默认样式

    在i标签下嵌套一个input标签  设置了 -webkit-apprarence:none: 设置了宽高,和padding:3px 结果placeholder显示不全 经排查 这时候的input默认有 ...

  7. C++的函数对象优于函数指针地方

    转载自:http://blog.csdn.net/huang_xw/article/details/7934156 在C++编程语言中,有很多功能都与C语言相通,比如指针的应用等等.在这里我们介绍的则 ...

  8. LR、HMM、CRF和MaxEnt区别

    LR:Logistic 是 Softmax 的特殊形式,多以如果 Softmax 与 MaxEnt 是等价的,则 Logistic 与 MaxEnt 是等价的. HMM模型: 将标注看作马尔可夫链,一 ...

  9. dockerfile基础命令

    一直想写一个, 但发现网上有很多了, 直接copy把 如何使用 Dockerfile用来创建一个自定义的image,包含了用户指定的软件依赖等.当前目录下包含Dockerfile,使用命令build来 ...

  10. 数据序列化导读(1)[JSON]

    所谓数据序列化(Data Serialization), 就是将某个对象的状态信息转换为可以存储或传输的形式的过程. 那么,为什么要进行序列化? 首先,为了方便数据存储: 其次,为了方便数据传递. 在 ...