自定义ListView加载动画,实现不一样的加载效果

本文详述如何利用animation和LayoutAnimation为ListView创建item显示动画。重点在于首次加载时生效,之后不会触发。示例包括相关XML配置和Java代码,同时解析了layoutAnimation属性和插值器的作用。下篇博客将探讨用Java为GridView设置动画。
摘要由CSDN通过智能技术生成

本篇博客主要介绍如何通过animation和LayoutAnimation来实现ListView的item显示动画。实现ListView中的item显示动画需要注意,这种动画只会在ListView第一次加载item的时候起作用,在之后的item重新绘制等一系列情况都不会起作用!!!这一点需要注意,确定是否符合你的需求!!!

先看一下效果图吧:
这里写图片描述这里写图片描述

看一下主布局文件吧(其实没什么好看的,就是一个listview):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ListView
        android:layoutAnimation="@anim/list_layout_animation"
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ListView>
</LinearLayout>

list_animation_1.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000">
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
    <translate
        android:fromXDelta=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值