放大和缩小动画的android大和、动画、android

2023-09-07 08:37:27 作者:从此形同陌路

我有正常code放大和缩小动画两项活动之间,但我想要的东西不同。我有我的第一个活动五个按钮,如果我点击第一个按钮,然后放大,将是从第一个按钮从中央变焦位置只,而不是开始。请帮我。

I have code of normally zoom in and zoom out animation between two activities, but I want something different. I have five buttons on my first activity if I click on first button then zoom in would be starts from position of first button only instead of zooming from centre. Please help me.

编辑:变焦应该从我点击为中心的按钮启动

EDIT : Zoom should start from the button I clicked as a centre.

推荐答案

您可以运行该命令后,使用此方法来启动新的活动,

You can use this method after running the command to start your new activity,

startActivity(intent);
overridePendingTransition(animation_in_goes_here,animation_out_goes_here);

然后你可能会取代你的动画上面,替换 animation_in_goes_here 你需要为你的新开工和更换活动的动画资源 animation_out_goes_here 与您离开该活动的动画资源。这会给你的切换特效。

Then you may replace your animations above, replacing the animation_in_goes_here with the animation resource you need for the activity that you have newly started and replacing animation_out_goes_here with the animation resource for the activity that you are leaving from. This will give you the switching effects.

zoom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
    <scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="3"
    android:toYScale="3" >
    </scale>
 </set>

zoom_out.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
    <scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="0.5"
    android:toYScale="0.5" >
    </scale>
 </set>

希望这有助于回答你的问题。

Hope this helped to answer your question.