自定义控件动画篇(七)layoutAnimation与gridLayoutAnimation的使用

在Android中,LayoutAnimationGridLayoutAnimation 是用来给布局内的子视图添加动画效果的。它们允许你对整个布局的显示过程进行动画处理,而不是单个视图。

LayoutAnimation

LayoutAnimation 可以应用于任何的布局管理器,如LinearLayout、RelativeLayout等。要使用LayoutAnimation,你首先需要在你的Activity或Fragment中找到对应的布局,然后设置一个LayoutAnimationController

如何使用LayoutAnimation
  1. 创建 LayoutAnimationController

     

    在XML中定义动画,例如:

     Xml 
    1<!-- res/anim/layout_fade_in.xml -->
    2<set xmlns:android="http://schemas.android.com/apk/res/android">
    3    <alpha
    4        android:fromAlpha="0.0"
    5        android:toAlpha="1.0"
    6        android:duration="300"/>
    7</set>

    然后,在代码中加载并设置给LayoutAnimationController

     Java 
    1// Java
    2Animation anim = AnimationUtils.loadAnimation(this, R.anim.layout_fade_in);
    3LayoutAnimationController controller = new LayoutAnimationContro
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值