新建一个Android project ,使MainActivity 继承自 ListActivity;

public class MainActivity extends ListActivity {

	private ArrayAdapter<String> aa;
private LayoutAnimationController la;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
aa=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_activated_1
, new String[]{"Jack","Tom","Mali","kelusi"});
setListAdapter(aa); ScaleAnimation scale=new ScaleAnimation(0,1,0,1);
scale.setDuration(1000);
la=new LayoutAnimationController(scale, 0.5f);
getListView().setLayoutAnimation(la);
} }

效果:

为了使代码看起来更加简洁,我们使用XML配置ListView的动画效果,新建一个缩放动画效果res/anim/listview_scale.xml:

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0" android:toXScale="1"
android:fromYScale="0" android:toYScale="1"
android:duration="1000"> </scale>

新建一个LayoutAnimation,res/anim/listview_anim.xml(虽然layoutAnimation没有智能提示,但一样可以使用):

让LayoutAnimation的Animation=listview_scale.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/listview_scale"
android:delay="0.5">
</layoutAnimation>

新建一个布局文件   main.xml,在布局 文件内添加一个ListView ,将LayoutAnimation效果 添加到ListView:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" > <ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/listview_anim">
</ListView>
</LinearLayout>

在这里需要特别注意,ListView的ID必须等 于

@android:id/list

后台代码就很简单 了,加载Main.xml即可

public class MainActivity extends ListActivity {

	private ArrayAdapter<String> aa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
aa=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_activated_1
, new String[]{"Jack","Tom","Mali","kelusi"});
setListAdapter(aa);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }

AndroidUI 布局动画-为列表添加布局动画效果的更多相关文章

  1. jQuery停止动画和判断是否处于动画状态

    1.停止元素的动画 stop([clearQueue][,gotoEnd]); 参数clearQHCHC和gotoEnd都足町选的参数,为Boolean值(ture或flase).clearQueue ...

  2. Android动画效果之自定义ViewGroup添加布局动画

    前言: 前面几篇文章介绍了补间动画.逐帧动画.属性动画,大部分都是针对View来实现的动画,那么该如何为了一个ViewGroup添加动画呢?今天结合自定义ViewGroup来学习一下布局动画.本文将通 ...

  3. 自定义ViewGroup添加布局动画

    声明几个属性值: <declare-styleable name="GridImageViewGroup"> <attr name="childVert ...

  4. CCS3的过渡、变换、动画以及响应式布局、弹性布局

    CSS3 过渡 .变换.动画 在没有CSS3之前,如果页面上需要一些动画效果,要么你自己编写 JavaScript,要么使用 JavaScript 框架(如 jQuery)来提高效率. 但是CSS3出 ...

  5. css盒子布局,浮动布局以及显影与简单的动画

    08.05自我总结 一.盒子布局 1.盒子布局的组成 margin border padding content 2.margin margin是外边距,控制盒子的显示位置相对于他的上一级 left. ...

  6. ListView在列表的头部和底部添加布局——addHeaderView,addFooterView

    addHeaderView()方法:主要是向listView的头部添加布局addFooterView()方法:主要是向listView的底部添加布局 以addHeaderView为例: View he ...

  7. Android使用shape制作圆形控件及添加弹跳动画

    --------本来为作者原创,未经同意禁止转载 前言:我们在很多时候都需要在res/drawable文件夹下创建相应的xml文件来为控件添加一些样式效果,比如按钮按下时的按钮样式变化.或者指定按钮的 ...

  8. Android为ViewPager添加切换动画——自己定义ViewPager

    转载请注明出处:http://blog.csdn.net/allen315410/article/details/44224517 在上篇博客中,我写了一个使用属性动画为ViewPager加入切换动画 ...

  9. 【Android 应用开发】AndroidUI设计之 布局管理器 - 详细解析布局实现

    写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...

随机推荐

  1. SQL Server 无法启动的 4 种原因

    SQL Server 无法启动的原因定位.首先要知道SQL Server 启动的过程. 第一步: 读取注册表,创建log文件.检测硬件.初始化系统配置. 第二步: 启动系统数据库. 第三步: 准备好网 ...

  2. Azure上如何在Linux下挂载数据磁盘

    [原文首次发表于51cto http://cloudapps.blog.51cto.com/3136598/1653672] 在Azure上创建了虚拟机之后,我们在一些情况下会需要添加更多的数据磁盘来 ...

  3. 【配置】如何配置Tp-link无线路由器作为无线交换机

    最近刚装了电信天翼宽带,谁知道现在只能装光猫.你说一个4M带宽有必要用光猫么?装好之后问题来了,这个光猫很奇葩,只有一个以太网接口,确有内置有路由功能,也就是只有一个出口的路由器.现在问题来了:我想接 ...

  4. thinkphp这样玩关联查询(实例教会你)

    thinkphp实例,内连接实现多表中同时查找,并存在了一个数组中,返回到模板中,模板中volist遍历即可使用多表中的字段 $row=M()->query("select realn ...

  5. Linux进程间通信——信号集函数

    一.什么是信号 用过Windows的我们都知道,当我们无法正常结束一个程序时,可以用任务管理器强制结束这个进程,但这其实是怎么实现的呢?同样的功能在Linux上是通过生成信号和捕获信号来实现的,运行中 ...

  6. [转]linux下IPTABLES配置详解

    如果你的IPTABLES基础知识还不了解,建议先去看看.开始配置我们来配置一个filter表的防火墙.(1)查看本机关于IPTABLES的设置情况[root@tp ~]# iptables -L -n ...

  7. 【POJ】3468 A Simple Problem with Integers ——线段树 成段更新 懒惰标记

    A Simple Problem with Integers Time Limit:5000MS   Memory Limit:131072K Case Time Limit:2000MS Descr ...

  8. Ubuntu 查找命令

    Ubuntu 查找文件夹 使用find命令查找find / -name 文件夹名称 -type d找到结果中含有路径 查找命令 从根目录开始查找所有扩展名为.log的文本文件,并找出包含”ERROR” ...

  9. vim 多窗口编辑

    本文出自   http://blog.csdn.net/shuangde800 ------------------------------------------------------------ ...

  10. 傅老师课堂:Java高级应用之Struts2+Spring2+Hibernate3大集成

    开篇一笑:一对情侣,非常恩爱,但男友喜欢说脏话,一天女友提出要带男友回家吃个饭,见见家长,千叮万嘱让男友别说脏话,男友在家憋了一晚上没说一句脏话,天气寒冷,到走的时候女友家长要出来送他们,男友客气的说 ...