android ListView增加Animation效果

简介:

anim文件夹下建立anim_layout.xml和alpha.xml

-----------------------android:animationOrder 的取值有normal 0 默认reverse 1 倒序random 2 随机-----------------------

anim_layout.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"  
  3.   
  4.  android:delay="0.5"  
  5.  android:animationOrder="random"  
  6.  android:animation="@anim/alpha"  
  7.  />  

alpha.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"  
  3.         android:interpolator="@android:anim/accelerate_interpolator">  
  4.           
  5.     <alpha  
  6.         android:fromAlpha="0.0"  
  7.         android:toAlpha="1.0"  
  8.         android:duration="500" />  
  9.       
  10. </set>  

布局文件里的ListView增加一个layoutAnimation属性

[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <ListView   
  8.         android:id="@id/android:list"  
  9.         android:layout_width="fill_parent"  
  10.         android:layout_height="fill_parent"  
  11.         android:drawSelectorOnTop="false"  
  12.         android:layoutAnimation="@anim/anim_layout"  
  13.         ></ListView>  
  14.       
  15.     <TextView  
  16.         android:id="@id/android:empty"  
  17.         android:layout_width="fill_parent"  
  18.         android:layout_height="fill_parent"  
  19.         android:text="No data" />  
  20.       
  21. </LinearLayout>  

相关文章
|
23小时前
|
API Android开发 开发者
Android UI设计: 什么是RecyclerView?为什么它比ListView更好?
Android UI设计: 什么是RecyclerView?为什么它比ListView更好?
33 2
|
23小时前
|
XML Java Android开发
如何美化android程序:自定义ListView背景
如何美化android程序:自定义ListView背景
|
23小时前
|
XML Java Android开发
Android Studio App入门之列表视图ListView的讲解及实战(附源码 超详细必看)
Android Studio App入门之列表视图ListView的讲解及实战(附源码 超详细必看)
101 0
|
23小时前
|
XML 编解码 Java
Android控件之高级控件——ListView、cardView、屏幕适配
Android控件之高级控件——ListView、cardView、屏幕适配
|
10月前
|
XML Java Android开发
|
5月前
|
XML Android开发 数据格式
安卓-无敌解决ListView添加标题头无法正常显示的问题(歪门邪道)
安卓-无敌解决ListView添加标题头无法正常显示的问题(歪门邪道)
40 0
|
7月前
|
Java Android开发
[笔记]Android 学习一之转场动画+ViewPager+ListView简单Demo
[笔记]Android 学习一之转场动画+ViewPager+ListView简单Demo
|
10月前
|
XML Android开发 数据格式
|
12月前
|
XML Java Android开发
Android优化版ListView(附源代码)
本文是博主对Adapter(适配器)的一些理解,为了加深对Adapter的理解以及记录自己的阶段学习而写,同时也适合初学者阅读,参考本条博客的逻辑进行学习。
119 0
|
XML API Android开发
Android 属性动画Property Animation(中)
ValueAnimator指定整形、浮点型或者颜色值作为动画值,在一定时间内平滑过渡。可以通过ofInt(),ofFloat(),或ofObject()来或得一个ValueAnimator