Android-LayoutAnimation

Android-LayoutAnimation

学习自

《Android开发艺术探索》

LayoutAnimation漫谈

LayoutAnimation 也是View动画的一种,作用是为ViewGroup的ChildView添加出场动画,我们经常回看到一些ListView的Item的出场效果很漂亮,就是通过LayoutAnimation实现的。

LayoutAnimation

layoutanimation.gif | left | 369x539

首先还是在 res/anim 目录下建立LayoutAnimation的Xml文件

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
    android:animation="@anim/item_in_set"
    android:animationOrder="normal"
    android:delay="0.2" />

属性解释

  • animation: ChildView的入场动画
  • animationOrder: 动画播放的顺序,其中有三个选项
    • normal 顺序显示
    • random 随机显示
    • reverse
  • delay 表示ChildView播放属性动画的延迟时间,假如说ViewChild动画播放的时间是300毫秒,那么 0.2 表示每个ChildView的动画播放都要比上一个ChildView的播放时间延迟 60毫秒 ,这样就有一个ChildView依次播放的特效了。

item_in_set 动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300">
    <alpha
        android:fromAlpha="0"
        android:toAlpha="1" />
    <translate
        android:fromYDelta="50%"
        android:toYDelta="0" />
</set>
posted @ 2018-07-23 09:51  鲁迅认识的那只猹  阅读(652)  评论(0编辑  收藏  举报