一、简介

二、代码
1.xml
(1)activity_main.xml

  1. <ListView
  2. android:id="@id/android:list"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:scrollbars="vertical"
  6. />
  7. <!-- android:layoutAnimation="@anim/list_anim_layout" -->
  8.  
  9. <Button
  10. android:id="@+id/buttonId"
  11. android:layout_width="fill_parent"
  12. android:layout_height="wrap_content"
  13. android:text="测试"
  14. />

(2)item.xml

  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" android:layout_height="fill_parent"
  4. android:orientation="horizontal" android:paddingLeft="10dip"
  5. android:paddingRight="10dip" android:paddingTop="1dip"
  6. android:paddingBottom="1dip">
  7.  
  8. <TextView android:id="@+id/user_name" android:layout_width="180dip"
  9. android:layout_height="30dip" android:textSize="5pt"
  10. android:singleLine="true"/>
  11. <TextView android:id="@+id/usr_gender" android:layout_width="fill_parent"
  12. android:layout_height="fill_parent" android:textSize="5pt"
  13. android:singleLine="true"/>
  14. </LinearLayout>

(3)res\anim\list_anim.xml

  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. android:shareInterpolator="true">
  5.  
  6. <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />
  7. </set>

(3)res\anim\list_anim_layout.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:delay="2"
  4. android:animationOrder="normal"
  5. android:animation="@anim/list_anim" />

2.java
(1)MainActivity.java

  1. package com.layoutanimationcontroller;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6.  
  7. import android.app.ListActivity;
  8. import android.os.Bundle;
  9. import android.view.View;
  10. import android.view.View.OnClickListener;
  11. import android.view.animation.Animation;
  12. import android.view.animation.AnimationUtils;
  13. import android.view.animation.LayoutAnimationController;
  14. import android.widget.Button;
  15. import android.widget.ListAdapter;
  16. import android.widget.ListView;
  17. import android.widget.SimpleAdapter;
  18.  
  19. public class MainActivity extends ListActivity {
  20.  
  21. private Button button = null;
  22. private ListView listView = null;
  23.  
  24. @Override
  25. protected void onCreate(Bundle savedInstanceState) {
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.activity_main);
  28. listView = getListView();
  29. button = (Button)findViewById(R.id.buttonId);
  30. button.setOnClickListener(new ButtonListener());
  31. }
  32.  
  33. class ButtonListener implements OnClickListener {
  34. @Override
  35. public void onClick(View v) {
  36. listView.setAdapter(buidListAdapter());
  37. Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.list_anim);
  38. LayoutAnimationController lac = new LayoutAnimationController(animation);
  39. lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
  40. lac.setDelay(0.5f);
  41. listView.setLayoutAnimation(lac);
  42. }
  43. }
  44.  
  45. private ListAdapter buidListAdapter() {
  46. List<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
  47. HashMap<String, String> m1 = new HashMap<String,String>();
  48. m1.put("user_name", "张三");
  49. m1.put("user_gender", "女");
  50.  
  51. HashMap<String, String> m2 = new HashMap<String, String>();
  52. m2.put("user_name", "李四");
  53. m2.put("user_gender", "女");
  54.  
  55. HashMap<String, String> m3 = new HashMap<String, String>();
  56. m3.put("user_name", "王五");
  57. m3.put("user_gender", "男");
  58.  
  59. list.add(m1);
  60. list.add(m2);
  61. list.add(m3);
  62.  
  63. SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, R.layout.item,
  64. new String[] {"user_name", "user_gender"},
  65. new int[] {R.id.user_name, R.id.usr_gender});
  66. return simpleAdapter;
  67. }
  68. }

ANDROID_MARS学习笔记_S02_011_ANIMATION_LayoutAnimationController的更多相关文章

  1. ANDROID_MARS学习笔记_S01_012_RatingBar

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  2. ANDROID_MARS学习笔记_S01_012_SeekBar

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  3. ANDROID_MARS学习笔记_S01_011ProgressBar

    文档是这样来设置样式 <ProgressBar android:layout_width="wrap_content" android:layout_height=" ...

  4. ANDROID_MARS学习笔记_S01_010日期时间控件

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  5. ANDROID_MARS学习笔记_S01_009Relative_LAYOUT例子

    1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...

  6. ANDROID_MARS学习笔记_S01_008Linear_layout例子

    1.netstone_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...

  7. ANDROID_MARS学习笔记_S01_007Linear_layout嵌套与layout_weight的设置

    一.介绍 二.1.linear_layout.xml <?xml version="1.0" encoding="utf-8"?> <Line ...

  8. ANDROID_MARS学习笔记_S01_006ImageView

    一.ImageView介绍 设置scalType Must be one of the following constant values. Constant Value Description ma ...

  9. ANDROID_MARS学习笔记_S01_005CheckBox

    一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...

随机推荐

  1. 两天来学习C的感受

    大学的时候曾经学习过C语言,教科书是谭浩强的绿色的书.当时根本没有好好学习,期末考试是靠老师画重点才过的. 那个时候稀里哗啦的完全听不明白,最揪心的是指针和文件操作(当时根本不知道这个世界上还有DB存 ...

  2. 谈谈asp.net中的<% %>,<%= %>,<%# %><%$ %>的使用

    学而不思则罔,思而不学则殆,每天坚持一小步,则成功一大步 asp.net中的<% %>,<%= %>,<%#eval("") %><%$ ...

  3. C#定义自定义类型转换

    类型转换不限于单一继承链中的类型(派生类转换为基类或者基类转换为派生类),完全不相关的类型之间也能进行转换.关键在于在两个类型之间提供转型操作符. 在下面这样的情况下应该定义显式转型操作符: 在转型有 ...

  4. libjingle线程机制

    libjingle包装了所有的线程,包括signaling thread,worker thread, 和其它任何线程,用talk_base::Thread来包装.所有的 Thread对象由Threa ...

  5. HTML5 Video与Audio 视频与音频

    ---- 视频Video对象 - 指定视频播放地址 <video width="320" height="240" controls="cont ...

  6. debian 学习记录-4 -关于linux -2

    来源:<Debian标准教程>王旭 著 Slackware.Debian.RedHat.SuSE 这4种发布版是当今大部分发布版的前去,虽然SuSE衍生自Slackware,但由于其技术变 ...

  7. PHP扩展开发(1):入门

    有关PHP扩展开发的文章.博客已经很多了,比较经典的有: TIPI项目(http://www.php-internals.com/,强烈推荐) <Extending and Embedding ...

  8. RX学习笔记:FreeCodeCamp的JavaScript基本算法挑战

    FreeCodeCamp的JavaScript基本算法挑战 https://www.freecodecamp.com 2016-07-03 JavaScript还不是非常熟悉,用已经会的知识来解这些题 ...

  9. width(),innerHTML(),outerHTML()

    HTML代码: <div id="box"> <p>哈哈,随便写点内容</p> <p>删除的实例</p> <p&g ...

  10. 纯javascript 回到 顶部 实例

    很多网站都会采用瀑布式的加载模式,像qq空间加载好友动态,为了用户体验更好,很多网站会加上回到顶部的连接,但大多数网站都是一下子就回到了顶部,当然,这样有这样的好处,但是我是个比较喜欢很炫的东西的人, ...