除了可以为视图添加动画以外,还可以为视图的布局添加动画;

<RelativeLayout 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"
tools:context=".MainActivity" > <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:id="@+id/linerLayout1"> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout> </RelativeLayout>

代码:

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout layout= (LinearLayout)findViewById(R.id.linerLayout1); //设置缩放动画
ScaleAnimation scale=new ScaleAnimation(0, 1, 0, 1);
scale.setDuration(3000);
//delay(动画延迟):0~1f,当第一个动画执行到什么地方的时候,下一个动画开始执行
//LayoutAnimationController controller=new LayoutAnimationController(scale, 0);
LayoutAnimationController controller=new LayoutAnimationController(scale, 0.5f);
//动画的执行顺序:ORDER_NORMAL(从上往 下);ORDER_RANDOM(随机执行);ORDER_REVERSE(从下往上)
// controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
controller.setOrder(LayoutAnimationController.ORDER_REVERSE);
layout.setLayoutAnimation(controller);
}
<pre name="code" class="java">//LayoutAnimationController controller=new LayoutAnimationController(scale, 0); //内部动画同时执行



<pre name="code" class="java">LayoutAnimationController controller=new LayoutAnimationController(scale, 0.5f); //内部动画延时执行

动画的执行顺序:ORDER_NORMAL(从上往 下):

ORDER_REVERSE(从下往上)

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

  1. iOS核心动画高级技巧之核心动画(三)

    iOS核心动画高级技巧之CALayer(一) iOS核心动画高级技巧之图层变换和专用图层(二)iOS核心动画高级技巧之核心动画(三)iOS核心动画高级技巧之性能(四)iOS核心动画高级技巧之动画总结( ...

  2. Android开发UI之补间动画-布局添加动画

    布局添加动画 使用步骤: 1.获取到布局的id RelativeLayout ly=(RelativeLayout)findViewById(R.id.layout); 2.设置动画样式 ScaleA ...

  3. [WPF自定义控件库]了解WPF的布局过程,并利用Measure为Expander添加动画

    1. 前言 这篇文章介绍WPF UI元素的两步布局过程,并且通过Resizer控件介绍只使用Measure可以实现些什么内容. 我不建议初学者做太多动画的工作,但合适的动画可以引导用户视线,提升用户体 ...

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

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

  5. iOS电商常见动画与布局、微信悬浮窗、音乐播放器、歌词解析、拖动视图等源码

    iOS精选源码 MXScroll 介绍 混合使用UIScrollView ios 电商demo(实现各种常见动画效果和页面布局) 一行代码集成微信悬浮窗 可拖动,大小的视图,可放置在屏幕边缘. 在使用 ...

  6. ACtivity实现欢迎界面并添加动画切换效果

    先看效果: 中间切换动画没来得及截图,凑合着看吧. 主要是java代码的实现: Welcom.java package kehr.activity.welcome; import android.ap ...

  7. 为Viewgourp内组件添加动画

    package com.loaderman.customviewdemo; import android.animation.Keyframe; import android.animation.La ...

  8. 仿喜马拉雅实现ListView添加头布局和脚布局

     ListView添加头布局和脚布局 之前学习喜马拉雅的时候做的一个小Demo,贴出来,供大家学习参考: 如果我们当前的页面有多个接口.多种布局的话,我们一般的选择无非就是1.多布局:2.各种复杂滑动 ...

  9. Android 在布局容器中动态添加控件

    这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理. 1.addView 添加控件到布局容器 2.removeView 在布局容器中删掉 ...

随机推荐

  1. Azure File SMB3.0文件共享服务(1)

    Azure Storage File是Azure推出的文件共享服务,目前的版本同时支持SMB 2.1和SMB 3.0协议.文件共享服务非常适合那些希望把自己数据中心中使用文件共享的应用程序,在云端需要 ...

  2. 抛弃QP

        随着软件的慢慢进行发现QP根本无法建立多个实例,也就是无法在多个任务中同时使用QP的事件回调 架构,这点同libevent不同,最终决定放弃之,乖乖的用freeRTOS多任务方案,workin ...

  3. error C2065: 'assert' : undeclared identifier

    F:\VC6.0 : error C2065: 'assert' : undeclared identifier 导入#include <assert.h>

  4. 区间dp-hdu-4745-Two Rabbits

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4745 题目意思: 给n个环状的数,A.B两人沿相反的方向走,每单位时间走一步,要求相同时间两人到达相 ...

  5. hdu 4686 Arc of Dream(矩阵快速幂乘法)

    Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai- ...

  6. 浅析WebGIS

    浅析WebGIS 摘要:随着网络的发展,利用Web公布信息越来越普及化.而地理信息系统(GIS)与网络的结合就产生了万维网地理信息系统(WebGIS),它引起了地理信息公布的新的变革,对实现GIS信息 ...

  7. C语言课程设计—图书管理系统

    这是本人大一第二学期初C语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中居然在QQ网络硬盘中找到了当初的teta版,公布于此,以作纪念. C源码例如以下: #include<std ...

  8. Linux下卸载ORACLE的多种方法(转)

    第一种# cd /u01/app/oracle/product/11.2.0/client_1/deinstall/ # ./deinstall# rm -rf /u01/app/oracle# rm ...

  9. golang之pkg(包)

    一.概述 Golang拥有超过100个标准包(可用go list std |wc -l查看) 任何包系统设计的目的都是简化大型程序的设计和维护工作,通过将一组相关的特性放进一个独立的模块以便于理解和更 ...

  10. How to Install/Deinstall Oracle Workspace Manager (文档 ID 263428.1)

    In this Document   Goal   Solution   References APPLIES TO: Workspace Manager - Version 9.0.1.0 to 1 ...