成都前几年网站建设公司,网站建设板块,搭建一个网站需要哪些技术,吉林省吉林市是几线城市ScaleAnimation动画是用来进行缩放的动画#xff0c;我在使用时刚开始有些不解的问题后来经过学习#xff0c;有了一个更深的了解。先来看看源码#xff0c;其实ScaleAnimation有四个构造函数#xff0c;这里我只列出了其中的一个#xff0c;因为另外的三个其实都只是这个…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轴方向的缩放尺寸。pivotXTypepivotYType代表着这个View动画执行的过程中你指定的伸缩原点相对于你的物件位置如何设置的方式。它共有三种模式分别为Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_PARENT分别代表着绝对位置相对于自己和相对于父布局的模式。当使用第一种时比较简单就是说把整个动画的缩放中心点设置在一个相对于你的View的一个绝对位置处。当使用Animation.RELATIVE_TO_SELF和Animation.RELATIVE_TO_PARENT就代表着你设定伸缩原点时使用相对位置这个相对位置的参照物可以是你自己也可以是父布局。pivotYValuepivotXValue这两个参数是和上面两个参数相关联的也就是说当我们使用上面的两个参数设置好我们相对于物件位置类型时我们使用这两个参数来说明我们到底把这个伸缩原点放到哪里。这里我们就不讨论Animation.ABSOLUTE这种情况了比较简单。我们讨论Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_PARENT这两种模式下的参数的使用。这两个参数是float类型是相对的位置值例如当你使用RELATIVE_TO_SELF模式并设置pivotXValue的值为0.5时就是说你的X轴方向的伸缩点设在你的这个View的X轴方向的中点处同样如果你在把Y轴设为一样的方式。那么也就确定了你的动画执行时的缩放原点为你的View的中心处从这个中心点开始变大或缩小。