如何从正确的缩放按钮,左,动画的android缩放、按钮、正确、动画

2023-09-08 09:58:34 作者:我的久伴不及她的一声轻唤

适用左至右规模TOA按钮,我使用了下列code。我的按钮布局的权利。我想要的按钮应该从正确的X位置和规模向左X位置开始如何实现这一目标?

  view.startAnimation(新ScaleAnimation(0.0,1.0F,1.0F,1.0F)); 

解决方案

您需要的起点设置在中间的权利,你也需要这样设置动画的持续时间:

  ScaleAnimation阿尼姆=新ScaleAnimation(0.0,1.0F,1.0F,1.0F,Animation.RELATIVE_TO_SELF,1.0F,Animation.RELATIVE_TO_SELF,0.5F));anim.setDuration(700);view.startAnimation(阿尼姆); 
android 怎么把button变成圆形

在你的情况在Y起始位置并不重要。

如果你不把它读到此构造:

  

公开ScaleAnimation(浮动fromX,TOX浮动,浮动弗罗米,浮玩具,INT pivotXType,浮pivotXValue,INT pivotYType,浮动  pivotYValue)

    

自:API等级1

    

构造函数,code建设ScaleAnimation时使用

    

参数:

    

fromX:水平缩放系数在动画开始适用

    

TOX:水平缩放系数在动画的最后申请

    

弗罗米:垂直缩放系数在动画开始适用

    

玩具:垂直缩放系数在动画的最后申请

    

pivotXType:指定pivotXValue应该如何跨preTED。其中一个Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF,或  Animation.RELATIVE_TO_PARENT。

    

pivotXValue:的X有关该对象被缩放的点的坐标,指定为绝对数,其中0为左  边缘。 (这一点而对象改变大小保持固定。)此  值可以是一个绝对数字,如果pivotXType是绝对的,还是  百分比(其中,1.0是100%),否则。

    

pivotYType:指定pivotYValue应该如何跨preTED。其中一个Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF,或  Animation.RELATIVE_TO_PARENT。

    

pivotYValue:在Y关于该对象被缩放的点的坐标,指定为绝对数,其中0是顶级  边缘。 (这一点而对象改变大小保持固定。)此  值可以是一个绝对数字,如果pivotYType是绝对的,还是  个(其中1.0为100%),否则。

To apply left to right scale toa button i have used the following code. My button is in the right of layout. I want the button should start from its right X position and scale to left X position how to achieve this?

view.startAnimation(new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f));

解决方案

You need to set the starting point to the middle right, you also need to set the duration of the animation like this:

ScaleAnimation anim = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,1.0f, Animation.RELATIVE_TO_SELF, 0.5f));
anim.setDuration(700);
view.startAnimation(anim);

in your case the Y start location is not important.

if you don't get it read about this constructor:

public ScaleAnimation (float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

Since: API Level 1

Constructor to use when building a ScaleAnimation from code

Parameters:

fromX: Horizontal scaling factor to apply at the start of the animation

toX: Horizontal scaling factor to apply at the end of the animation

fromY: Vertical scaling factor to apply at the start of the animation

toY: Vertical scaling factor to apply at the end of the animation

pivotXType: Specifies how pivotXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.

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.

pivotYType: Specifies how pivotYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.

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.