动画库

我用过的动画


ListView

方式一、静态添加(可以复用)

① 在 anim文件夹创建 item动画:item_anim.xml,即每一条数据载入时的动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"           android:fillAfter="true">
    <translate 
        android:fromXDelta="100%"
        android:toXDelta="0"
        android:fromYDelta="0"
        android:toYDelta="0"
        android:duration="88"
        />
    <alpha 
        android:fromAlpha="0.1"
        android:toAlpha="1"
        android:duration="238"
        />
</set>

② 创建动画文件:listview_animation.xml ,注意根元素是LayoutAnimation

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

③ 在布局文件中,为ListView控件添加LayoutAnimation属性并设值

android:layoutAnimation="@anim/listview_animation"

方式二、代码中添加

① 同上,创建item动画:item_anim.xml
② 在代码中创建Layout 动画,并为ListView 对象设置

LayoutAnimationController listViewAnim = new LayoutAnimationController(
                AnimationUtils.loadAnimation(this, R.anim.item_anim));
        listViewAnim.setDelay(0.2f);
        listViewAnim.setOrder(LayoutAnimationController.ORDER_NORMAL);
        listView.setLayoutAnimation(listViewAnim);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值