如何从正确的缩放按钮,左,动画的android [英] How to scale a button from right to left, android animation

查看:691
本文介绍了如何从正确的缩放按钮,左,动画的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

适用左至右规模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(阿尼姆);

在你的情况在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.

这篇关于如何从正确的缩放按钮,左,动画的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆