[Android Pro] Android的Animation之LayoutAnimation使用方法
用于为一个里面的控件,或者是一个里面的控件设置动画效果,可以在文件中设置,亦可以在代码中设置。
一种直接在XML文件中设置
1. 在res/anim文件夹下新建一个XML文件,名为list_anim_layout.xml,
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="30%"
android:animationOrder="reverse"
android:animation="@anim/slide_right" />
android:delay 子类动画时间间隔 (延迟) 70% 也可以是一个浮点数 如“1.2”等
android:animationOrder="random" 子类的显示方式 random表示随机
android:animationOrder 的取值有
| normal | 0 | 默认 |
| reverse | 1 | 倒序 |
| random | 2 | 随机 |
android:animation="@anim/slide_right" 表示孩子显示时的具体动画是什么
说明:其中delay的单位为秒;animation为设置动画的文件。animationOrder为进入方式
2. 在res/anim文件夹下新建一个XML文件,名为slide_right,即上面用到的文件。
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>
显示的效果为ListView第一次出现的时候为 item随机出现 每个Item都是从左不可见(-100%p)的区域向右滑动到显示的地方
3. 在主布局文件中为控件添加如下配置:
android:layoutAnimation="@anim/list_anim_layout",即第一步的布局文件。
第二种设置方法:在Java代码中设置
1. 同上;
2. 同上;
4. 在Acitivty中添加如下代码:
//通过加载XML动画设置文件来创建一个Animation对象;
Animation animation=AnimationUtils.loadAnimation(this,
R.anim.list_anim);
//得到一个LayoutAnimationController对象;
LayoutAnimationController lac=new LayoutAnimationController(animation);
//设置控件显示的顺序;
lac.setOrder(LayoutAnimationController.ORDER_REVERSE);
//设置控件显示间隔时间;
lac.setDelay(1);
//为ListView设置LayoutAnimationController属性;
datalist.setLayoutAnimation(lac);
[Android Pro] Android的Animation之LayoutAnimation使用方法的更多相关文章
- [Android Pro] Android权限设置android.permission完整列表
android.permission.ACCESS_CHECKIN_PROPERTIES允许读写访问"properties”表在checkin数据库中,改值可以修改上传( Allows re ...
- [Android Pro] Android开发实践:自定义ViewGroup的onLayout()分析
reference to : http://www.linuxidc.com/Linux/2014-12/110165.htm 前一篇文章主要讲了自定义View为什么要重载onMeasure()方法( ...
- [Android Pro] Android开发实践:为什么要继承onMeasure()
reference to : http://www.linuxidc.com/Linux/2014-12/110164.htm Android开 发中偶尔会用到自定义View,一般情况下,自定义Vie ...
- [Android Pro] Android TypedValue.applyDimension()的用法
reference to : http://blog.csdn.net/voo00oov/article/details/45745819 这个方法的作用是 把Android系统中的非标准度量尺寸转 ...
- [Android Pro] android 4.4 Android原生权限管理:AppOps
reference : http://m.blog.csdn.net/blog/langzxz/45308199 reference : http://blog.csdn.net/hyhyl1990/ ...
- [Android Pro] Android 4.1 使用 Accessibility实现免Root自动批量安装功能
reference to : http://www.infoq.com/cn/articles/android-accessibility-installing?utm_campaign=info ...
- [Android Pro] Android 4.3 NotificationListenerService使用详解
reference to : http://blog.csdn.net/yihongyuelan/article/details/40977323 概况 Android在4.3的版本中(即API 18 ...
- [Android Pro] Android签名与认证详细分析之二(CERT.RSA剖析)
转载自: http://www.thinksaas.cn/group/topic/335449/ http://blog.csdn.net/u010571535/article/details/899 ...
- [Android Pro] android 杀死进程的方法
1: 杀死自己进程的方法 android.os.Process.killProcess(Process.myPid()); 2:杀死别人进程的方法(不能杀死自己) -------a: activity ...
随机推荐
- CentOS下配置FTP
http://www.cnblogs.com/zhenmingliu/archive/2012/04/25/2470646.html 常见错误: 1.FTP服务器已经拒绝 解决方案 # setenfo ...
- 【python】发送邮件
从网上找了一些用python发邮件的教程,学习一下: 1.发送普通的文本邮件 http://www.cnblogs.com/xiaowuyi/archive/2012/03/17/2404015.ht ...
- hdu 1664(数论+同余搜索+记录路径)
Different Digits Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Set Matrix Zeroes——常数空间内完成
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Did yo ...
- 确实,k8s的时代,ingress负载用traefik比nginx方便啊
参考文档: https://mritd.me/2016/12/06/try-traefik-on-kubernetes/#13ingress 由于微服务架构以及 Docker 技术和 kubernet ...
- 【JBPM4】流程部署
示例代码: ProcessEngine processEngine = Configuration.getProcessEngine(); RepositoryService repositorySe ...
- CentOS7.5安装坚果云
1.下载坚果云rpm包,对于CentOS,选fedora那个版本的包 https://www.jianguoyun.com/s/downloads/linux 2.安装 坚果云安装依赖notify-p ...
- 轻松学习LINUX系列教程推出
本系列多媒体教程已完成的博文: 1.轻松学习Linux之入门篇 http://chenguang.blog.51cto.com/350944/449214 2.轻松学习Linux之本地安装系统 (分区 ...
- 从零开始做SSH项目(一)
1.数据库脚本 用户表 CREATE TABLE `ybl`.`userinfo`( `id` INT NOT NULL AUTO_INCREMENT, `email` ) NOT NULL, `id ...
- jsp页面中获取session中的值
Jsp中获取Session: session是jsp的内置对象,所以你可以直接写在jsp的 <% session.setAttribute("a", b); //把b放到se ...