LayoutAnimation-容器动画
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-容器动画的更多相关文章
- [Android Pro] ListView,GridView之LayoutAnimation特殊动画的实现
转载自:http://gundumw100.iteye.com/blog/1874545 LayoutAnimation干嘛用的?不知道的话网上搜一下. Android的Animation之Layou ...
- React Native超棒的LayoutAnimation(布局动画)
该文翻译自:https://medium.com/@Jpoliachik/react-native-s-layoutanimation-is-awesome-4a4d317afd3e#.6 ...
- android studio上的基本动画实现(第一篇)
hello,各位小伙伴们,在很多小伙伴们刚刚开始学习android的时候,常常会有一些project里面需要有一些基本动画的插入,那么具体是要怎么实现呢?我们接下一起分析一下在android中的几种基 ...
- CSS动画与GPU
写在前面 满世界的动画性能优化技巧,例如: 只允许改变transform.opacity,其它属性不要动,避免重新计算布局(reflow) 对动画元素应用transform: translate3d( ...
- 安卓开发_浅谈Android动画(三)
一.LayoutAnimation布局动画 用于为一个layout里面的控件,或者是一个ViewGroup里面的控件设置动画效果 在res-anim文件下新建一个动画xml文件 <?xml ve ...
- 你会用swift创建复杂的加载动画吗(1)
时至今日,iOS 应用商店已经拥有超过了140万 应用,让你自己的应用脱颖而出确实是个不小的挑战.不过,在你的应用掉入默默无闻的大黑洞之前,你拥有一个小小的机遇窗,它能帮你吸引用户的注意. AD: 时 ...
- Android下设置ListView数据加载完成后执行layoutanimation
今天使用android的volley框架写了一个简单的网络天气获取的demo. 承载数据的空间是ListView 因为是网络加载,必然先要设置ListView的默认数据,我设置的就是那个Loading ...
- android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)
1.layout切换动画 代码: 本示例是fragment切换.在它的oncreateView中 public class LayoutAnimationFrgmt extends Fragment ...
- ReactNative入门(安卓)——API(下)
LayoutAnimation - layout动画 当布局发生改变时的动画模块,它有两个方法: 1. 最常用的方法是 LayoutAnimation.configureNext(conf<Ob ...
- Android Drawable资源
Android实现应用d动画效果:比如App第一次打开的开始动画等 有两种:GIF动画和代码实现. 第一种:借助于Gif制作工具软件实现.一般是和第三方开源的GifView(https://githu ...
随机推荐
- kafka offset的存储问题
注意:从kafka-0.9版本及以后,kafka的消费者组和offset信息就不存zookeeper了,而是存到broker服务器上,所以,如果你为某个消费者指定了一个消费者组名称(group.id) ...
- 图解RHEL6从安装光盘中进行yum安装
图解RHEL6从安装光盘中进行yum安装 导读:我们这里讲的Yum,是Yellow dog Updater, Modified的缩写,可执行程序名为yum,它的理念是使用一个中心仓库(reposito ...
- 超级硬件代理解决企业Web提速上网问题
超级硬件代理解决企业Web提速上网问题 需求分析: XX集团是五家企业重组建立的特大型工程勘察设计咨询企业,下设10多个分公司,上网人数众多.有多台WEB server,对外服务,访问量及大.以前无论 ...
- 解决MyEclipse中安装或升级ADT之后SDK Target无法显示的问题
故障现象,在MyEclipse里面安装完最新的android sdk和ADT之后,无法新建项目,Build Target为空,显示一直在loading.即如下面图里面显示的,Target Na ...
- ttf字体转换成web中使用的woff、svg、eot格式字体
网站地址:http://www.fontsquirrel.com/tools/webfont-generator(还可以缩小字体文件大小,强烈推荐) ttf转换成eot格式的字体软件:EOTFAST. ...
- 代码正常,junit却报错原因及解决方法
junit测试,不能有参数 和static,去掉static测试正常;
- Nginx模型 & 惊群问题
这篇写的不错 http://www.cnblogs.com/linguoguo/p/5511293.html Nginx为啥性能高-多进程异步IO模型 1. 对于每个worker进程来说,独立的进程, ...
- java同步包种ArrayBlockingQueue类的分析与理解
前言: ArrayBlockingQueue类是一个堵塞队列.重要用于多线程操作的条件. 一,官方解释 一个建立在数组之上被BlockingQueue绑定的堵塞队列.这个队列元素顺序是先进先出.队列的 ...
- NumPy基础入门学习
对于习惯使用了MATLAB的用户而言,学习NumPy这个python工具包付出的成本应该是不大的. NumPy的基本的object是多维数组,是一个有同样类型的数字等构成的一张表格,能够通过元组进行索 ...
- qmake生成Visual Studio工程
整个Qt在Windows中都可以通过批处理来编译,当编译好Qt后,会生成qmake.exe. 在没有安装Qt-VS-Addin的情况下,如何使用别人提供的Qt *.pro项目文件呢? 使用qmake可 ...