我有两个活动之间正常放大和缩小动画的代码,但我想要一些不同的东西。我的第一个活动有五个按钮,如果我点击第一个按钮,那么放大将只从第一个按钮的位置开始,而不是从中心开始。请帮帮我。
编辑:缩放应该从我点击的按钮开始作为中心。
发布于 2013-07-28 22:01:21
您可以在运行命令后使用此方法来启动新的活动。
startActivity(intent);
overridePendingTransition(animation_in_goes_here,animation_out_goes_here);
然后,您可以替换上面的动画,将animation_in_goes_here
替换为新启动的活动所需的动画资源,并将animation_out_goes_here
替换为要离开的活动的动画资源。这将为您提供切换效果。
zoom_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3"/>
</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
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"/>
</set>
希望这能帮助回答你的问题。
发布于 2016-06-15 15:41:39
放大
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5">
</scale>
缩小
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="2.1"
android:fromYScale="2.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="3000"
android:toXScale="0"
android:toYScale="0">
</scale>
发布于 2013-07-28 13:37:04
我认为你必须这样做:
anim
object.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_enter)); object.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_exit));
您可以使用google在Apache2.0许可下提供的android sdk示例动画
或者参考这个,它使用基于缩放的缩放,这比前者更容易
https://stackoverflow.com/questions/17904432
复制相似问题