感谢慕课网--eclipse_xu

布局文件:activity_main.xml

 <FrameLayout 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"
tools:context="com.example.animationapp.MainActivity" > <ImageView
android:id="@+id/im0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/b" /> <ImageView
android:id="@+id/im1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/c" /> <ImageView
android:id="@+id/im2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/d" /> <ImageView
android:id="@+id/im3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/e" /> <ImageView
android:id="@+id/im4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/f" /> <ImageView
android:id="@+id/im5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/g" /> <ImageView
android:id="@+id/im6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingTop="3dp"
android:src="@drawable/h" /> <ImageView
android:id="@+id/im7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/a" /> </FrameLayout>

图片资源

MainActivity.java

 package com.example.animationapp;

 import java.util.ArrayList;
import java.util.List; import android.support.v7.app.ActionBarActivity;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.BounceInterpolator;
import android.widget.ImageView;
import android.widget.Toast; public class MainActivity extends ActionBarActivity implements OnClickListener { private int[] res = {R.id.im0, R.id.im1,R.id.im2,
R.id.im3,R.id.im4,R.id.im5,R.id.im6,R.id.im7}; private List<ImageView> list = new ArrayList<ImageView>(); private boolean flag = true; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); initView();
} private void initView() { for(int i = 0; i < res.length; i++){
ImageView im = (ImageView) findViewById(res[i]);
im.setOnClickListener(this);
list.add(im);
}
} @Override
public void onClick(View v) {
switch(v.getId()){
//im7最后布局,叠加在最上面
case R.id.im7:{ if(flag){
startAnimation();
flag = false;
}else{
closeAnimation();
flag = true;
}
break;
} default:
Toast.makeText(MainActivity.this, v.getId()+"OK", Toast.LENGTH_SHORT).show();
break;
}
} private void closeAnimation() {
for(int i = 0 ;i<res.length-1; i++){
ObjectAnimator oa = ObjectAnimator.ofFloat(list.get(i),
"translationY",i*200F, 0F );
oa.setDuration(100);
//oa.setStartDelay(50*i);
oa.start();
}
} private void startAnimation() {
//此处只需要弹出其余7个图标,最上边的图标im7不动
for(int i = 0 ;i<res.length-1; i++){
//属性动画操作类
ObjectAnimator oa = ObjectAnimator.ofFloat(list.get(i),
"translationY", 0F, i*200F);
oa.setDuration(200);
//oa.setInterpolator(new BounceInterpolator());
//oa.setStartDelay(200*i);
oa.start();
}
} }

ObjectAnimator属性动画应用demo的更多相关文章

  1. ObjectAnimator属性动画示例代码

    import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Ac ...

  2. Android属性动画之第一重修炼总结

    经过这两天对ObjectAnimator属性动画的学习,基本对Android提供的属性动画有了一定的认识,现在就为大家以一个类似扇形打开的效果做总结. 效果图: 下面就让我们用刚刚学到的属性动画效果, ...

  3. Android 属性动画框架 ObjectAnimator、ValueAnimator ,这一篇就够了

    前言 我们都知道 Android 自带了 Roate Scale Translate Alpha 多种框架动画,我们可以通过她们实现丰富的动画效果,但是这些宽家动画却有一个致命的弱点,它们只是改变了 ...

  4. Android基础夯实--重温动画(五)之属性动画 ObjectAnimator详解

    只有一种真正的英雄主义 一.摘要 ObjectAnimator是ValueAnimator的子类,它和ValueAnimator一样,同样具有计算属性值的功能,但对比ValueAnimator,它会更 ...

  5. 【转】android 属性动画之 ObjectAnimator

    原文网址:http://blog.csdn.net/feiduclear_up/article/details/39255083 前面一篇博客讲解了 android 简单动画之 animtion,这里 ...

  6. Android属性动画之ObjectAnimator

    相信对于Android初学者,对于Android中的动画效果一定很感兴趣,今天为大家总结一下刚刚学到的属性动画案例. 首先和一般的Android应用一样,我们先建一个工程,为了方便,我们的布局文件中就 ...

  7. Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/43536355 大家好,在上一篇文章当中,我们学习了Android属性动画的基本用法 ...

  8. android 开发 View _2_ View的属性动画ObjectAnimator ,动画效果一览

    支持:https://www.cnblogs.com/whoislcj/p/5738478.html translationX的效果: protected void onCreate(Bundle s ...

  9. Android 属性动画ObjectAnimator和ValueAnimator讲解

    区别: ObjectAnimator 是直接对某个view进行更改. ValueAnimator 根据 TimeInterpolator 在不断产生相应的数据,来传进view  ,view自己做改变. ...

随机推荐

  1. 初探nodeJS

    一.node概要 对nodeJS早有耳闻,但是一直迟迟没有对它下手,哈哈哈,今儿咱就来初探一下它. nodeJS是个啥东东? nodeJS,我的理解就是可以运行在后端的JavaScript. 为什么它 ...

  2. ES6 - Note4:Class类

    1.Class类的介绍 在ES6中新增了Class类的概念,让语法看起来更像是面向对象编程,其实这可以说是一个语法糖,ES5可以做到Class绝大部分功能,但也有一些不同.在ES6以前,可以通过构造函 ...

  3. 【续集】在 IIS 中部署 ASP.NET 5 应用程序遭遇的问题

    dudu 的一篇博文:在 IIS 中部署 ASP.NET 5 应用程序遭遇的问题 针对 IIS 部署 ASP.NET 5 应用程序的问题,在上面博文中主要采用两种方式尝试: VS2015 的 Publ ...

  4. RESTful API URI 设计: 判断资源是否存在?

    相关的一篇文章:RESTful API URI 设计的一些总结. 问题场景:判断一个资源(Resources)是否存在,URI 该如何设计? 应用示例:判断 id 为 1 用户下,名称为 window ...

  5. CSS3实现圆形进度条

    介绍 闲来无事,去了CSS3Plus网站逛了逛,发现了一个很有意思的实现--css3实现进度条.粗略看了下代码,发现原理其实很简单,不难理解. 现在在此讲述下原理并实现一个1s更新的进度条. 技术细节 ...

  6. 1Z0-053 争议题目解析498

    1Z0-053 争议题目解析498 考试科目:1Z0-053 题库版本:V13.02 题库中原题为: 498.The database Is configured in ARCHIVELOG mode ...

  7. LeetCode - 404. Sum of Left Leaves

    Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...

  8. DotNet指定文件显示的尺寸

    在项目中开发中,有时候需要将文件的尺寸进行控制,例如需要将文件的尺寸指定为字节,TB等.现在提供一个方法,实现将指定文件的尺寸, 提供:"字节", "KB", ...

  9. DotNet隐藏敏感信息操作方法

    在项目中,有时候一些信息不便完全显示,只需要显示部分信息.现在提供一些隐藏敏感信息的操作方法,主要为对信息的截取操作: 1.指定左右字符数量,中间的*的个数和实际长度有关: /// <summa ...

  10. Scala 中下划线的用途

    转载自:https://my.oschina.net/leejun2005/blog/405305 Scala 作为一门函数式编程语言,对习惯了指令式编程语言的同学来说,会不大习惯,这里除了思维方式之 ...