`
rayln
  • 浏览: 424671 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Animation动画效果四

 
阅读更多
如何使用layoutAnimation
首先: 需要创建一个layoutAnimation的配置文件, 定义动画的步骤和引用动画
然后: 在需要动画效果的控件中加入android:layoutAnimation="@anim/list_anim_layout".

一个完成的例子:

首先/res/anim/alpha.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator">
    <alpha android:fromAlpha="0" android:toAlpha="1" android:duration="2000"/>
</set>


新建一个/res/anim/list_anim_layout.xml
<?xml version="1.0" encoding="utf-8"?><!-- animationOrder: random, normal -->
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="2" android:animationOrder="normal" android:animation="@anim/alpha"></layoutAnimation>


这个/res/layout/activity.xml是ListView用的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="50px">
    <TextView android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical"/>  
	<TextView android:id="@+id/view2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"/>
</LinearLayout>


/res/layout/main.xml主文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
	<TextView  
	    android:layout_width="fill_parent" 
	    android:layout_height="wrap_content" 
	    android:text="@string/hello"
	    />
	<ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layoutAnimation="@anim/list_anim_layout"></ListView>
	<Button android:text="Button" android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="setAlphaClick"></Button>
</LinearLayout>


Animation3Activity.java文件
package com.cn;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class Animation3Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
    }
    private void createListView(){
    	List<Map<String,String>> list = new ArrayList<Map<String,String>>();  
    	Map<String,String> map = new HashMap<String,String>();  
    	map.put("姓名", "小王");  
    	map.put("年龄", "12");  
    	list.add(map);
    	map = new HashMap<String,String>();  
    	map.put("姓名", "小王");  
    	map.put("年龄", "12");  
    	list.add(map);
    	map = new HashMap<String,String>();  
    	map.put("姓名", "小王");  
    	map.put("年龄", "12");  
    	list.add(map);
    	ListView view = (ListView)findViewById(R.id.listView1);  
    	view.setAdapter(new SimpleAdapter(this, list, R.layout.activity, new String[]{"姓名","年龄"}, new int[]{R.id.view1,R.id.view2}));  
//    	setContentView(view);
    }
    
    public void setAlphaClick(View v){
    	createListView();
    }
}

分享到:
评论

相关推荐

    iphone用Animation实现动画效果

    在本教程中,我们将深入探讨如何使用`UIView`的`animation`方法来创建简单的上、中、下移动动画效果。这涉及到iOS开发中的基本动画原理,以及如何通过代码控制视图的行为。 首先,我们要理解`UIView`动画的基本概念...

    wpf Animation动画效果演示,包含多个实例

    在本文中,我们将深入探讨WPF(Windows Presentation Foundation)中的动画效果,并通过多个实例来展示其强大功能。WPF Animation是微软.NET Framework的一部分,它为开发者提供了丰富的视觉表现手法,可以实现平滑...

    微信小程序 鲜花订购,animation动画卡片效果 (源码)

    微信小程序 鲜花订购,animation动画卡片效果 (源码)微信小程序 鲜花订购,animation动画卡片效果 (源码)微信小程序 鲜花订购,animation动画卡片效果 (源码)微信小程序 鲜花订购,animation动画卡片效果 (源码)微信...

    微信小程序源码 鲜花订购,animation动画卡片效果(学习版)

    微信小程序源码 鲜花订购,animation动画卡片效果(学习版)微信小程序源码 鲜花订购,animation动画卡片效果(学习版)微信小程序源码 鲜花订购,animation动画卡片效果(学习版)微信小程序源码 鲜花订购,animation动画...

    微信小程序源码(含截图)鲜花订购,animation动画卡片效果

    微信小程序源码(含截图)鲜花订购,animation动画卡片效果微信小程序源码(含截图)鲜花订购,animation动画卡片效果微信小程序源码(含截图)鲜花订购,animation动画卡片效果微信小程序源码(含截图)鲜花订购,...

    微信小程序实现animation动画

    微信小程序实现animation动画,具体内容如下 1. 创建动画实例 wx.createAnimation(OBJECT) 创建一个动画实例animation。调用实例的方法来描述动画。最后通过动画实例的export方法导出动画数据传递给组件的...

    动画包_animation动画效果_源码

    "动画包_animation动画效果_源码"这个资源包,显然是为了帮助开发者理解和实现各种动画效果而准备的。它可能包含了一系列使用了Android内置的animation库编写的示例代码。下面将详细讨论Android中的动画技术及其重要...

    微信小程序——鲜花订购,animation动画卡片效果(截图+源码).zip

    微信小程序——鲜花订购,animation动画卡片效果(截图+源码).zip 微信小程序——鲜花订购,animation动画卡片效果(截图+源码).zip v微信小程序——鲜花订购,animation动画卡片效果(截图+源码).zip 微信小程序...

    animation动画效果

    总结,OC的动画效果是通过Core Animation和UIKit提供的API实现的,涵盖了从简单到复杂的各种动画需求。理解这些基础知识和技巧,开发者能够创造出富有吸引力和交互性的iOS应用。在实际开发中,根据项目需求灵活运用...

    Animation动画实例源代码

    本资源“Animation动画实例源代码”提供了一系列详细实例,帮助开发者深入了解和实践Android中的动画技术。这些实例适用于ADT(Android Development Toolkit)版本10及ECLIPSE JUNO开发环境。 Android动画主要包括...

    css3弹力球动画animation属性制作3D弹力球弹跳动画效果

    这个动画效果不仅增强了用户界面的视觉吸引力,还能提供更好的交互体验。接下来,我们将深入探讨如何利用CSS3的`animation`属性来制作这样一个3D弹力球动画。 首先,我们需要理解`animation`属性的基本结构。它是一...

    frameAnimation动画效果

    帧动画(Frame Animation)是Android系统提供的一种基本的动画机制,它通过连续播放一系列静态图像来创造出动态的效果,类似于我们小时候看的翻页动画书。在手机软件开发中,帧动画常用于创建简单的过渡效果、加载...

    使用animation翻页动画效果

    本主题将深入探讨如何使用`animation`类动画效果来实现手机页面的翻页效果,这是一种常见的视觉过渡手段,使得用户在浏览内容时感觉更加自然和舒适。 一、动画基础 在计算机图形学中,动画是通过连续展示一系列...

    android Animation动画实现loading效果

    除了原生的Android动画,还有许多第三方库提供丰富的加载动画效果,如`android-Universal-Image-Loader`、`Glide`、`Picasso`等图片加载库均支持添加自定义加载动画。此外,还有专门为加载效果设计的库,如`...

    Animation动画的解析与自定义Animation动画

    本篇文章将深入解析Android中的动画系统,并探讨如何自定义Animation动画。 首先,Android提供了两种主要的动画机制:属性动画(Property Animation)和视图动画(View Animation)。属性动画是在Android 3.0(API ...

    Animation动画效果

    "Animation动画效果"这个主题涵盖了多种技术和概念,下面将对其进行详细阐述。 1. **基本动画原理**:动画的基本原理是通过连续显示一系列微小变化的静态图像来创建动态视觉效果。这些图像通常被称为帧,而帧率(如...

    Core Animation动画例子

    通过这个“Core Animation动画例子”压缩包,你可以学习到如何在实践中运用上述知识点,创建出流畅、精致的iOS应用动画效果。记住,实践是最好的老师,深入研究并动手尝试这些示例,将有助于你更好地掌握Core ...

    LoadingAnimation 动画 加载动画

    - **固定帧动画**:由一系列静态图像按顺序播放构成,常用于创建简单的连续动画效果。在Android中,这可以通过`AnimationDrawable`类实现。 2. **AnimationTest**: - 这个文件名可能对应的是一个测试项目或者一...

    Android Tween Animation动画效果详解

    Android Tween Animation动画的使用demo,以及自定义动画,原理解析,相关博客: http://blog.csdn.net/w18756901575/article/details/53081551

Global site tag (gtag.js) - Google Analytics