2C02-View-Layout-Animation-list-Cascade

描述list layout item有上倒下依次显示的代码实现形式

LayoutAnimation2.java

/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.apis.view;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class LayoutAnimation2 extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, mStrings));

        AnimationSet set = new AnimationSet(true);

        Animation animation = new AlphaAnimation(0.0f, 1.0f);
        animation.setDuration(50);
        set.addAnimation(animation);

        animation = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
        );
        animation.setDuration(100);
        set.addAnimation(animation);

        LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
        ListView listView = getListView();
        listView.setLayoutAnimation(controller);
    }

    private String[] mStrings = {
        "Bordeaux",
        "Lyon",
        "Marseille",
        "Nancy",
        "Paris",
        "Toulouse",
        "Strasbourg"
    };
}

2C02-View-Layout-Animation-list-Cascade

时间: 2024-08-29 07:25:44

2C02-View-Layout-Animation-list-Cascade的相关文章

Transition FrameWork

Android Transition Framework可以实现三种效果: 不同Activity之间切换时,Activityc的内容(contentView)转场动画 不同Activity之间切换时,如果使用了Shared Element动画,也可以使用Transition FrameWork来实现不同的过渡动画效果 同一个Activity内View变化的过渡动画(Scene) 1. Activity之间切换的过渡动画 通过这种方法可以使activity切换时,他们的布局内容有过度动画 当从Ac

【Android 动画】View Animation详解(一)

安卓平台目前提供了两大类动画,在Android 3.0之前,一大类是View Animation,包括Tween animation(补间动画),Frame animation(帧动画),在android3.0中又引入了一个新的动画系统:property animation,即属性动画.本篇文章主要介绍View Animation的基本使用方法与技巧,属性动画将在下一篇博文中介绍. Tween动画可以执行一系列简单变换(位置,大小,旋转,缩放和透明度).所以,如果你有一个TextView对象,您

Customize the View Items Layout 自定义视图项目布局

In this lesson, you will learn how to customize the default editor layout in a Detail View. For this purpose, the Contact Detail View will be used. 在本课中,您将学习如何在详细视图中自定义默认编辑器布局.为此,将使用"联系人详细信息"视图. Note 注意 Before proceeding, take a moment to review

android通过xml文件实现Animation动画

Rotate的xml文件编写方法 <rotate android:fromDegrees="0" android:toDegrees="+350" android:pivotX="50%" android:pivotY="50%" android:duration="1000"/> *android:toDegrees="+350"正号代表的是旋转方向,正号为顺时针,负号为逆

Android动画学习笔记-Android Animation

转自:http://www.cnblogs.com/angeldevil/archive/2011/12/02/2271096.html 3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中又引入了一个新的动画系统:property animation,这三种动画模式在SDK中被称为property animation,view animation,drawable animation. 可通过NineOldAndr

Android View 深度分析requestLayout、invalidate与postInvalidate

requestLayout 当我们动态移动一个View的位置,或者View的大小.形状发生了变化的时候,我们可以在view中调用这个方法,即: 1 view.requestLayout(); 那么该方法的作用是什么呢? 从方法名字可以知道,“请求布局”,那就是说,如果调用了这个方法,那么对于一个子View来说,应该会重新进行布局流程.但是,真实情况略有不同,如果子View调用了这个方法,其实会从View树重新进行一次测量.布局.绘制这三个流程,最终就会显示子View的最终情况.那么,这个方法是怎

Android 自定义View修炼-打造完美的自定义侧滑菜单/侧滑View控件(转)

一.概述 在App中,经常会出现侧滑菜单,侧滑滑出View等效果,虽然说Android有很多第三方开源库,但是实际上 咱们可以自己也写一个自定义的侧滑View控件,其实不难,主要涉及到以下几个要点: 1.对Android中Window类中的DecorView有所了解 2.对Scroller类实现平滑移动效果 3.自定义ViewGroup的实现 首先来看看效果图吧:    下面现在就来说说这里咱们实现侧滑View的基本思路吧,这里我采用的是自定义一个继承于RelativeLayout的控件叫做XC

[转]Android Animation

3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中又引入了一个新的动画系统:property animation,这三种动画模式在SDK中被称为property animation,view animation,drawable animation. 1. View Animation(Tween Animation) View Animation(Tween Animation):补间动画,给出两个关键帧,通过一

Android移动view动画问题--停在动画的最后一帧(转)

Android写动画效果不是一般的麻烦,网上找了好久,终于解决了动画的问题,总结记录以共勉. 仅以水平方向移动效果做说明,垂直方向类似. public void slideview(final float p1, final float p2) { TranslateAnimation animation = new TranslateAnimation(p1, p2, 0, 0); animation.setInterpolator(new OvershootInterpolator());

Android动画Animation简单示例

Animation是Android给我们提供的一个可以实现动画效果的API,利用Animation我们可以实现一系列的动画效果,比如缩放动画,透明度动画,旋转动画,位移动画,布局动画,帧动画等等.Android基础动画分为四种,分别是Tween Animation,Frame Animation,Layout Animation,Property Animation.由于动画效果不好用图片进行展示,大家可以自己亲手试试看下效果.下面给出前三种简单的示例代码,帮助大家进行简单的动画入门. (1)