普通动画效果和属性动画效果区别:

普通动画效果的动画播放后只是产生了视觉欺骗,并没有移动真实的控件。

属性动画直接真实的移动控件

AnimationSet动画:

TextView t1 = (TextView)findViewById(R.id.textView6);
TextView t2 = (TextView)findViewById(R.id.textView7); //设置移动
AnimationSet animationSet = new AnimationSet(true);
TranslateAnimation translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF,-2f,
Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF,0f
);
//设置透明度
AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
//添加进去
animationSet.addAnimation(translateAnimation);
animationSet.addAnimation(alphaAnimation);
animationSet.setDuration(500);
t1.startAnimation(animationSet);
t1.setVisibility(View.GONE);

属性动画:

RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.foot);

            float curTranslationY = relativeLayout.getTranslationY();
ObjectAnimator animator = ObjectAnimator.ofFloat(relativeLayout, "translationY", curTranslationY, -300f);
animator.setDuration(200);
animator.start();

总的来说属性动画执行的动画效果后控件的位置也会发生改变,解决了很多麻烦。

ObjectAnimator animator = ObjectAnimator.ofFloat(relativeLayout, "translationY", curTranslationY, -300f);

这里的4个参数分别代表的是

1.要进行操作的控件

2.执行的动画效果,我这里的是沿着Y移动 translationX 是沿着X轴移动 rotationX 就是旋转了

至于后面的几个参数就是移动的位置了如果添加第5个参数那么 3 - 5 的参数代表的就是 (从第3个参数移动到第4个参数,然后返回到第5个参数)

ObjectAnimator animator = ObjectAnimator.ofFloat(relativeLayout, "translationY", curTranslationY, -300f,curTranslationY);

上面的代码代表的就是从curTranslationY开始移动 移动到 -300f 然后 返回到 curTranslationY 的位置。

animator.setDuration(200);
animator.start();

上面第一行代码代表整个动画执行的时间,这里是200毫秒。

最后一行代码开始执行动画效果。

Android开发属性动画的更多相关文章

  1. Android开发——View动画、帧动画和属性动画详解

    0. 前言   Android动画是面试的时候经常被问到的话题.我们都知道Android动画分为三类:View动画.帧动画和属性动画. 先对这三种动画做一个概述: View动画是一种渐进式动画,通过图 ...

  2. android使用属性动画代替补间动画

    本文参考Android属性动画完全解析(上),初识属性动画的基本用法 android3.0之前一共有两种动画,分别是frame动画和tween动画,关于这两种动画如果不了解可以查看我之前的文章andr ...

  3. Android开发学习——动画

    帧动画> 一张张图片不断的切换,形成动画效果* 在drawable目录下定义xml文件,子节点为animation-list,在这里定义要显示的图片和每张图片的显示时长              ...

  4. 【Android】属性动画

    转载请注明出处:http://blog.csdn.net/h28496/44338669 属性动画的原理 通过不断的设置一个View的属性让其出现动画效果.比如,不断地设置一个Button的x值.这个 ...

  5. Android之属性动画(二)

    上一篇文章(链接:http://www.cnblogs.com/jerehedu/p/4458928.html  ),我们对属性动画有了简单的认识,并实际动手使用ObjectAnimator.Anim ...

  6. Android之属性动画(一)

    一.概述 Android平台中常用的动画主要有两类,一类是View动画,一类是3.0后新增的属性动画.属性动画与View动画相比功能更加强大,主要体现在以下两个方面: 1.  属性动画不仅仅能应用到V ...

  7. android开发之动画的详解 整理资料 Android开发程序小冰整理

    /** * 作者:David Zheng on 2015/11/7 15:38 * *  网站:http://www.93sec.cc * *  微博:http://weibo.com/mcxiaob ...

  8. IOS开发-属性动画和关键帧动画的使用

    CAMediaTiming是一个协议(protocol),CAAnimation是所有动画类的父类,但是它不能直接使用,应该使用它的子类. 继承关系: CoreAnmiation 核心动画 简写CA ...

  9. Android使用属性动画ValueAnimator动态改变SurfaceView的背景颜色

    以下是主要代码,难点和疑问点都写在注释中: /** * 开始背景动画(此处为属性动画) */ private void startBackgroundAnimator(){ /* *参数解释: *ta ...

随机推荐

  1. @Pointcut的用法

    在Spring 2.0中,Pointcut的定义包括两个部分:Pointcut表示式(expression)和Pointcut签名(signature).让我们先看看execution表示式的格式: ...

  2. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence

    #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...

  3. Linux内核分析第五周总结

    系统调用在内核代码中的工作机制和初始化 xyz()与sys_xyz()是通过系统调用号联系在一起的 0x80与system_call是通过中断向量联系起来的 系统调用机制的初始化 用汇编代码编写系统调 ...

  4. html之间传递参数

    转自:http://blog.163.com/yangzhanghui_job/blog/static/179575062201271624839972/ aa.html 往 bb.html 传参 a ...

  5. 【转】STM32和ARM的区别

    转自:http://www.cnblogs.com/nuc-boy/archive/2012/09/11/2680157.html 这个问题大概2009年的时候很多人就在问,请看09年的时候大家给出的 ...

  6. HDU 2053 Switch Game

    http://acm.hdu.edu.cn/showproblem.php?pid=2053 Problem Description There are many lamps in a line. A ...

  7. Activiti Rest API tutorial

    http://192.168.66.182:8080/activiti-rest/service/repository/deployments/ {"data":[{"i ...

  8. [转帖]Linux的进程线程及调度

    Linux的进程线程及调度 本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/10393707.html 本文为宋宝华<Linux的进程 ...

  9. iphone 与 PC端电脑投屏设置

    1. iphone端安装: 屏幕投影助手 下载地址 https://itunes.apple.com/cn/app/ping-mu-tou-ying-zhu-shou/id1152332174?mt= ...

  10. python 安装influxdb-python

    一.Linux下安装 1.yum install -y git 2.安装pip,参考:https://app.yinxiang.com/shard/s41/sh/0338ba85-5443-453f- ...