0
我在我的应用程序中使用放大动画的视图。当用户点击一个按钮时,下一个活动从该按钮中放大。 This是我使用下面给出的代码实现的。缩小动画 - Android
由于在上面提到的视频中,显示的代码仅适用于糖果软糖和以上我不得不使用下面给出的代码。
Next_Activity.java
Bundle b = getIntent().getExtras(); // Bundle passed from previous activity to this activity
x = b.getInt("X"); //b is button in previous activity
y = b.getInt("Y"); //b is button in previous activity
xh = b.getInt("XH"); //b is button in previous activity
yh = b.getInt("YH"); //b is button in previous activity
AnimationSet set = new AnimationSet(true);
width = display.getWidth();
height = display.getHeight();
Animation scale = new ScaleAnimation((float)xh/width, 1f, (float)yh/height , 1f, x, y);
Animation alpha = new AlphaAnimation(.75f, 1f);
set.addAnimation(scale);
set.addAnimation(alpha);
set.setDuration(300);
main.startAnimation(set); //main is rootLayout of this activity
Main_Activity(带按钮的活动)
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??
}
我能明白这一点我自己。但是,如何反转放大动画?你可以告诉我这条线的缩小动画 '动画scale = new ScaleAnimation((float)xh/width,1f,(float)yh/height,1f,x,y);' –
@DroidFan我是害怕我不知道'ScaleAnimation'构造函数中的六个参数是指什么。如果我这样做了,我可能会帮助你,但到现在为止,他们对我来说是任意数字。 – Adam
请再次查看代码。我已经发布了这两个活动以及参数。我无法做的是扭转动画线。谢谢! –