ScaleAnimation动画是用来进行缩放的动画,我在使用时刚开始有些不解的问题
后来经过学习,有了一个更深的了解。
先来看看源码,其实ScaleAnimation有四个构造函数,这里我只列出了其中的一个,因为
另外的三个其实都只是这个构造函数的一种特殊情况,这里我就只分析这个构造函数。

 /*** Constructor to use when building a ScaleAnimation from code* * @param fromX Horizontal scaling factor to apply at the start of the*        animation* @param toX Horizontal scaling factor to apply at the end of the animation* @param fromY Vertical scaling factor to apply at the start of the*        animation* @param toY Vertical scaling factor to apply at the end of the animation* @param pivotXType Specifies how pivotXValue should be interpreted. One of*        Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or*        Animation.RELATIVE_TO_PARENT.* @param pivotXValue The X coordinate of the point about which the object*        is being scaled, specified as an absolute number where 0 is the*        left edge. (This point remains fixed while the object changes*        size.) This value can either be an absolute number if pivotXType*        is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.* @param pivotYType Specifies how pivotYValue should be interpreted. One of*        Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or*        Animation.RELATIVE_TO_PARENT.* @param pivotYValue The Y coordinate of the point about which the object*        is being scaled, specified as an absolute number where 0 is the*        top edge. (This point remains fixed while the object changes*        size.) This value can either be an absolute number if pivotYType*        is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.*/public ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {mResources = null;mFromX = fromX;mToX = toX;mFromY = fromY;mToY = toY;mPivotXValue = pivotXValue;mPivotXType = pivotXType;mPivotYValue = pivotYValue;mPivotYType = pivotYType;initializePivotPoint();}

参数如下
float fromX 动画起始时 X坐标上的伸缩尺寸
float toX 动画结束时 X坐标上的伸缩尺寸   
float fromY 动画起始时Y坐标上的伸缩尺寸   
float toY 动画结束时Y坐标上的伸缩尺寸   
int pivotXType 动画在X轴相对于物件位置类型   
float pivotXValue 动画相对于物件的X坐标的开始位置   
int pivotYType 动画在Y轴相对于物件位置类型   
float pivotYValue 动画相对于物件的Y坐标的开始位置

说明
fromX,fromY
代表着你的这个View动画执行开始时的X轴方向和Y轴方向的缩放
尺寸,当为1.0f时就代表这和原来大小相同,当为2.0就是在X轴或Y轴方向上2倍尺寸大小。

toX,toY
和上边一样,代表着你的这个View动画执行结束时的X轴方向和Y轴方向的缩放
尺寸。

pivotXType,pivotYType
代表着这个View动画执行的过程中你指定的伸缩原点相对于你的物件位置如何设置的方式。它共有三种
模式,分别为Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_PARENT
分别代表着绝对位置,相对于自己和相对于父布局的模式。当使用第一种时,比较简单,就是说把整个
动画的缩放中心点设置在一个相对于你的View的一个绝对位置处。当使用Animation.RELATIVE_TO_SELF和Animation.RELATIVE_TO_PARENT
就代表着你设定伸缩原点时使用相对位置,这个相对位置的参照物可以是你自己也可以是父布局。

pivotYValue,pivotXValue
这两个参数是和上面两个参数相关联的,也就是说当我们使用上面的两个参数设置好我们相对于物件位置类型时,
我们使用这两个参数来说明我们到底把这个伸缩原点放到哪里。这里我们就不讨论Animation.ABSOLUTE这种情况了
,比较简单。我们讨论Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_PARENT这两种模式下的参数的使用。
这两个参数是float类型,是相对的位置值,例如当你使用RELATIVE_TO_SELF模式并设置pivotXValue的值为0.5时,
就是说你的X轴方向的伸缩点设在你的这个View的X轴方向的中点处,同样如果你在把Y轴设为一样的方式。那么也就确定了
你的动画执行时的缩放原点为你的View的中心处,从这个中心点开始变大或缩小。

ScaleAnimation动画相关推荐

  1. android scaleanimation动画,Android 的ScaleAnimation 缩放动画基本运用

    因为今天用到了ScaleAnimation缩放动画就写一下,加深一下印象. 用ScaleAnimation有几个重载方法,这里就将八个参数的重载方法. ScaleAnimation(float fro ...

  2. android scaleanimation动画,【Android动画九章】-RotateAnimation(旋转动画)和ScaleAnimation(尺寸动画)...

    [Android动画九章]-RotateAnimation(旋转动画)和ScaleAnimation(尺寸动画) public abstract class Animation extends Obj ...

  3. android scaleanimation动画,Android 动画之ScaleAnimation应用详解

    android中提供了4中动画: AlphaAnimation 透明度动画效果 ScaleAnimation 缩放动画效果 TranslateAnimation 位移动画效果 RotateAnimat ...

  4. android scaleanimation动画,Animation之ScaleAnimation(缩放动画片)

    Animation之ScaleAnimation(缩放动画) ScaleAnimation(缩放动画) 缩放的意思就是对图片或者文字等进行扩大或缩小.下面开始编写代码,相关重要属性参数的解释都在代码中 ...

  5. android scaleanimation 动画方向,Animation 动画详解(一)——alpha、scale、translate、rotate、set的xml属性及用法...

    一.概述 Android的animation由四种类型组成:alpha.scale.translate.rotate,对应android官方文档地址:<Animation Resources&g ...

  6. Android 动画之ScaleAnimation应用详解

    本节讲解ScaleAnimation 动画在应用中的实现,有需要的朋友可以参考下 android中提供了4中动画: AlphaAnimation 透明度动画效果 ScaleAnimation 缩放动画 ...

  7. 在android中执行多个动画,Android上几种Animation和多个动画同时播放以ScaleAnimation应用详解...

    在API Demo的View->Animation下可以找到四个Animation的Demo,第一个3D Translate比较复杂,最后再讲,先讲第2个Interpolator.该Activi ...

  8. Android 动画之ScaleAnimation应用具体解释

    android中提供了4中动画: AlphaAnimation 透明度动画效果 ScaleAnimation 缩放动画效果 TranslateAnimation 位移动画效果 RotateAnimat ...

  9. android 减速动画,Android View Animation

    概述 可译为视图动画,分为 缩放动画 平移动画 渐变动画 旋转动画 Android系统中定义了一个抽象类Animation来定义这种视图动画,它的具体子类如下表: 动画名称 对应的子类 xml中标签 ...

最新文章

  1. 理解 OpenStack Swift (2):架构、原理及功能 [Architecture, Implementation and Features]...
  2. 二分查找算法的两种实现方式:非递归实现和递归实现
  3. services.xml应该放在项目的哪里_行车中手机支架到底应该放在哪里呢?出风口、方向盘、仪表台?...
  4. 【POJ - 2762】Going from u to v or from v to u?(Tarjan缩点,树形dp 或 拓扑排序,欧拉图相关)
  5. itextsharp c# asp.net 生成 pdf 文件
  6. 一个CXF集成SPRING的WEBSERVICE完整实例
  7. spring整合mybatis的坑
  8. 请君入瓮:研究员找到 Emotet 的bug,并成功阻止传播
  9. Ubuntu 环境变量文件介绍
  10. NPAPI插件开发详细记录:插件开发入门
  11. HDU2177——取(2堆)石子游戏(威佐夫博弈)
  12. php奖学金系统,java/php/net/pythont奖助学金管理系统设计
  13. 生信搬运工-02-sra文件的下载
  14. java 循环详解_Java for循环详解
  15. SGD平行算法 - Downpour SGD (单机python多线程版)
  16. 【STDC】《Rethinking BiSeNet For Real-time Semantic Segmentation》
  17. 【校招VIP】互联网校招项目实习对项目的要求不重要?大错特错!你忽略掉的项目考察重点都在这里!
  18. 使用VIVADO LICENSE 加密VHDL/Verilog 文件(二)
  19. wordpress最佳架构_25个最佳免费WordPress商业主题
  20. java -jar 工作原理_Spring Boot 的java -jar命令启动原理详解

热门文章

  1. Socket代码实现服务端 和 客户端之间通信
  2. 使用Remix编写Solidity语言的小例子
  3. 算法入门篇四 桶排序
  4. 幸福秘诀 男女必须要看哦
  5. 用Linux命令行修图——缩放、编辑、转换格式——一切皆有可能
  6. JSch:Java Secure Channel -- java 代码实现 ssh 远程操作
  7. Linux ping命令、Linux kill命令、Linux logname命令、 Linux logout命令
  8. Java中十六进制转换 Integer.toHexString()
  9. Django congtent types应用
  10. Spring Boot—07应用application.properties中的配置