1.LayoutAnimation的作用主要就是加载到一个layout上,让这个layout里面的所有控件都有相同的动画效果。现在用到的是在listview中添加动画,使得它每一个item都是滑落显示

首先看一下在代码中的实现方法,代码如下

import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.LayoutAnimationController; private Animation myHistoryAnimation;
private LayoutAnimationController myLayoutControl; myHistoryAnimation = (Animation) AnimationUtils.loadAnimation(
this, R.anim.history_clear_anim);
myLayoutControl = new LayoutAnimationController(myHistoryAnimation);
myLayoutControl.setDelay(0.4f);
//myLayoutControl.setOrder(LayoutAnimationController.ORDER_NORMAL);
myLayoutControl.setOrder(LayoutAnimationController.ORDER_REVERSE); mHistoryDisplayList.setLayoutAnimation(myLayoutControl);

2,其中history_clear_anim.xml内容如下

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true" > <alpha
android:duration="1000"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
<translate
android:duration="1000"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="40%" /> </set>

3.从上面我们可以看出,这个LayoutAnimation的应用也是非常的简单。

就是获得一个item想要的动画效果:AnimationUtils.loadAnimation( this, R.anim.history_clear_anim);

然后以它作为参数,创建一个LayoutAnimation对象:new LayoutAnimationController

然后就是在需要的地方添加一次动画:注意,只有执行它添加语句以后接下来的动画起一次作用

4.如果我们想要在xml中实现的话,如下

我们只要以上面的history_clear_anim.xml为一个动画属性创建一个xml文件就行了

<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.5"
android:animationOrder="normal"
android:animation="@anim/history_clear_anim"
/>

然后在我们的listview控件下使用

<ListView>
android:layoutAnimation="@animator/list_anim_layout"
</ListView>

这里我们看一下

android:animationOrder="normal"

属性,它有三个值

1.normal:加载的时候,动画从第一个加载项开始

2.random:加载的时候,动画随机执行

3.reverse:加载的时候,动画从最后一个开始执行

LayoutAnimation-容器动画的更多相关文章

  1. [Android Pro] ListView,GridView之LayoutAnimation特殊动画的实现

    转载自:http://gundumw100.iteye.com/blog/1874545 LayoutAnimation干嘛用的?不知道的话网上搜一下. Android的Animation之Layou ...

  2. React Native超棒的LayoutAnimation(布局动画)

          该文翻译自:https://medium.com/@Jpoliachik/react-native-s-layoutanimation-is-awesome-4a4d317afd3e#.6 ...

  3. android studio上的基本动画实现(第一篇)

    hello,各位小伙伴们,在很多小伙伴们刚刚开始学习android的时候,常常会有一些project里面需要有一些基本动画的插入,那么具体是要怎么实现呢?我们接下一起分析一下在android中的几种基 ...

  4. CSS动画与GPU

    写在前面 满世界的动画性能优化技巧,例如: 只允许改变transform.opacity,其它属性不要动,避免重新计算布局(reflow) 对动画元素应用transform: translate3d( ...

  5. 安卓开发_浅谈Android动画(三)

    一.LayoutAnimation布局动画 用于为一个layout里面的控件,或者是一个ViewGroup里面的控件设置动画效果 在res-anim文件下新建一个动画xml文件 <?xml ve ...

  6. 你会用swift创建复杂的加载动画吗(1)

    时至今日,iOS 应用商店已经拥有超过了140万 应用,让你自己的应用脱颖而出确实是个不小的挑战.不过,在你的应用掉入默默无闻的大黑洞之前,你拥有一个小小的机遇窗,它能帮你吸引用户的注意. AD: 时 ...

  7. Android下设置ListView数据加载完成后执行layoutanimation

    今天使用android的volley框架写了一个简单的网络天气获取的demo. 承载数据的空间是ListView 因为是网络加载,必然先要设置ListView的默认数据,我设置的就是那个Loading ...

  8. android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)

    1.layout切换动画 代码: 本示例是fragment切换.在它的oncreateView中 public class LayoutAnimationFrgmt extends Fragment ...

  9. ReactNative入门(安卓)——API(下)

    LayoutAnimation - layout动画 当布局发生改变时的动画模块,它有两个方法: 1. 最常用的方法是 LayoutAnimation.configureNext(conf<Ob ...

  10. Android Drawable资源

    Android实现应用d动画效果:比如App第一次打开的开始动画等 有两种:GIF动画和代码实现. 第一种:借助于Gif制作工具软件实现.一般是和第三方开源的GifView(https://githu ...

随机推荐

  1. jquery中prop()方法和attr()方法

    接着上一篇笔记的疑惑,找了下prop()方法和attr()方法的区别. 原来query1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. ...

  2. SpringMVC框架的多表查询和增删查改

    必须声明本文章==>http://www.cnblogs.com/zhu520/p/7883268.html 一: 1):我的运行环境 我使用myeclipse(你也可以使用eclipse),t ...

  3. qqwry - 纯真ip库的golang服务

    qqwry 纯真 IP 库的一个服务.通过http提供一个ip地址归属地查询支持 软件介绍 我们大家做网站的时候,都会需要将用户的IP地址转换为归属地址功能,而之前的作法大都是从硬盘的数据文件中读取, ...

  4. javaweb:判断当前请求是否为移动设备访问

    http://blog.csdn.net/educast/article/details/71157932

  5. cogs 1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292]

    1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292] ★   输入文件:DragonUVa.in   输出文件:DragonUVa.out   简单对比时间 ...

  6. 思科2960trunk vlan配置及路由IP配置

    en conf t vlan id end conf t inter rang gi 0/0/1-x switchport access vlan id no shutdown exit (confi ...

  7. js---13 this call apply

    //this:this可以写在js全剧环境中(全局环境中this是window对象),this可以写在函数中,可以写在对象中, function f(){ this.name = "asdf ...

  8. 42.cnpm不是内部命令的解决方案:配置环境变量

    转自:https://blog.csdn.net/u014540814/article/details/78777961

  9. 洛谷 P3385 【模板】负环

    P3385 [模板]负环 题目描述 暴力枚举/SPFA/Bellman-ford/奇怪的贪心/超神搜索 输入输出格式 输入格式: 第一行一个正整数T表示数据组数,对于每组数据: 第一行两个正整数N M ...

  10. PHP GD 生成图片验证码+session获取储存验证码

    以下分享一个PHP制作的图片验证码案例:案比例如以下图: 运用PHP GD具体请看:http://www.php.net/manual/zh/book.image.php 后台图片代码例如以下: &l ...