缩小动画-Android

缩小动画-Android,android,android-animation,Android,Android Animation,我正在我的应用程序中对视图使用放大动画。当用户单击按钮时,下一个活动将从该按钮放大。是我使用下面给出的代码实现的 因为在上面提到的视频中,显示的代码只适用于jellybean,我必须使用下面给出的代码 下一个\u Activity.java(带有放大动画的活动) 主活动(带按钮的活动) 现在,我的问题是如何反转这个动画?我的意思是,当我点击按钮时,活动从该按钮放大。那么,当按下后退按钮时,如何将活动缩小到同一个按钮 @Override public void onBackPressed() {

我正在我的应用程序中对视图使用放大动画。当用户单击按钮时,下一个活动将从该按钮放大。是我使用下面给出的代码实现的

因为在上面提到的视频中,显示的代码只适用于jellybean,我必须使用下面给出的代码

下一个\u Activity.java(带有放大动画的活动)

主活动(带按钮的活动)

现在,我的问题是如何反转这个动画?我的意思是,当我点击按钮时,活动从该按钮放大。那么,当按下后退按钮时,如何将活动缩小到同一个按钮

@Override
public void onBackPressed()
{
Animation scale = new ScaleAnimation( (float)xh/width, 1f, (float)yh/height , 1f, x, y);
// What is the zoom out animation of the above line??
}

我自己也能弄明白。但是如何反转动画中的缩放?你能告诉我这一行的缩小动画吗
animation scale=new ScaleAnimation((float)xh/width,1f,(float)yh/height,1f,x,y)
@droifan我恐怕不知道
ScaleAnimation
构造函数中的六个参数指的是什么。如果我这样做了,我可能会帮助你,但到目前为止,它们对我来说是任意数字。请再次查看代码。我已经发布了活动和论点所指的内容。我不能做的是反转动画线。谢谢我在Android开发者网站上发现构造函数是
ScaleAnimation(float-fromX,float-toX,float-fromY,float-toY,float-pivotX,float-pivotY)
。由此判断,我的猜测是将
fromX
/
fromY
分别与
toX
/
玩具
值交换。然后它看起来像
Animation scale=new ScaleAnimation((1f,(float)xh/width,1f,(flaot)yh/height,x,y);
谢谢!我会试试看!
   Bundle bundle = new Bundle();
   int[] xy = new int[2];

   button.getLocationOnScreen(xy);

   bundle.putInt("X", xy[0] + (b.getWidth() / 2));
   bundle.putInt("Y", xy[1] + (b.getHeight() / 2));
   bundle.putInt("XH", b.getWidth());
   bundle.putInt("YH", b.getHeight());

   Intent startnextactivity = new Intent(Table_main.this,Next_Activity.class);
   startnextactivity.putExtras(bb);
   startActivity(startnextactivity);
@Override
public void onBackPressed()
{
Animation scale = new ScaleAnimation( (float)xh/width, 1f, (float)yh/height , 1f, x, y);
// What is the zoom out animation of the above line??
}
@Override
public void onBackPressed() {
    Bundle b = getIntent().getExtras();
    x = b.getInt("X");
    y = b.getInt("Y");
    xh = b.getInt("XH");
    yh = b.getInt("YH");
    AnimationSet set = new AnimationSet(true);
    width = display.getWidth();
    height = display.getHeight();
    Animation scale = new ScaleAnimation((1f, (float) xh/width, 1f, (flaot) yh/height, x, y);
    Animation alpha = new AlphaAnimation(.75f, 1f);
    set.addAnimation(scale);
    set.addAnimation(alpha);
    set.setDuration(300);
    main.startAnimation(set);   
}