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边理解。有错误要指教哦,亲

  • 相关阅读:
    ThinkPHP5 动态生成图片缩略图
    2020年python学习进阶方向
    2020年一线大厂月薪35K的Python开发要求
    swoole扩展怎么用
    如何在PHP框架里把Traits使用起来
    php与Redis实现一个100万用户的投票项目,如何实现实时查看投票情况?
    PHP高并发和大流量的解决方案
    phper使用MySQL 针对千万级的大表要怎么优化?
    swoole加密可破解吗
    轻松玩转windows之redis实战
  • 原文地址:https://www.cnblogs.com/beenupper/p/2589956.html
Copyright © 2011-2022 走看看