Android-LayoutAnimation

学习自

《Android开发艺术探索》

LayoutAnimation漫谈

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

LayoutAnimation

Android-LayoutAnimation

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

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:andro
    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:andro
    android:duration="300">
    <alpha
        android:fromAlpha="0"
        android:toAlpha="1" />
    <translate
        android:fromYDelta="50%"
        android:toYDelta="0" />
</set>

相关文章:

  • 2021-07-28
  • 2021-05-19
  • 2021-06-04
  • 2021-06-21
  • 2021-06-25
  • 2022-12-23
  • 2021-10-18
  • 2021-08-26
猜你喜欢
  • 2022-01-21
  • 2021-12-10
  • 2021-07-24
  • 2022-02-22
  • 2021-05-24
  • 2021-11-02
  • 2021-11-14
相关资源
相似解决方案