zoukankan      html  css  js  c++  java
  • TranslateAnimation详解

    TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta);

    从(fromXDelta,fromYDelta)坐标点移动到(toXDelta,toYDelta)坐标点。这些坐标点指的是增量坐标。

    如:当前View在(10,10)坐标点。
      1.TranslateAnimation(0,10,0,10);即为以当前点为起始点偏移x=10,y=10的距离。
    效果为当前View从自己的位置移动到了自己位置下方的(10,10)点

      2.TranslateAnimation(10,20,10,20);即为以起始点(当前x+10,当前y+10),移动到终点(当前x+20,当前y+20)。
    效果为当前View跳跃到相对于当前位置的(10,10)点,移动到了相对于当前位置的(20,20)点
            
    明白增量坐标的意思了吧




    TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
     移动的坐标还是增量坐标。

     Type分为Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT
    说明Value如何解释。
     当为Animation.ABSOLUTE,为绝对位置。如10,既为相对于当前位置增量为10的坐标点
     当为Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT为百分比(0-1.0)。
    如:
    fromXType=Animation.RELATIVE_TO_SELF
    fromXValue=0
    意思为按自身的宽高来算Value,x=宽*value;y=高*value
    fromXValue=0相当于Animation.ABSOLUTE下的0
    fromXValue=0.5相当于Animation.ABSOLUTE下的宽*value为值
    fromXValue=1.0相当于Animation.ABSOLUTE下的View宽度为值


    new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.ABSOLUTE, 10,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.ABSOLUTE, 10);
    设View的宽为100,高为50

    就是从(100*0.5,50*0.5)的增量点移动到(10,10)增量点
    明白了吧。我是明白了。我也是边写demo边理解。有错误要指教哦,亲

  • 相关阅读:
    程序跳过UAC研究及实现思路(两种方法,现在可能都不行了)
    getch(),getche(),getchar()的区别
    命令行版扫雷(vc08)
    类成员函数指针的特殊之处(成员函数指针不是指针,内含一个结构体,需要存储更多的信息才能知道自己是否virtual函数)
    WCF与Web API 区别
    扩展方法库
    开源Dubbox
    AngularJs应用页面
    浅谈可扩展性框架:MEF
    AngularJs + ASP.NET MVC
  • 原文地址:https://www.cnblogs.com/beenupper/p/2589956.html
Copyright © 2011-2022 走看看