2

我正在开发一个在 android 中带有缩放动画的应用程序。就像在按钮 onclick 事件中转到下一个活动一样,在该活动上我有一个图像,该图像应该用动画放大。如果有人遇到这个帮助我。

4

2 回答 2

5

在您的下一个 ActivityonCreate()方法中使用此代码

ImageView imageView = (ImageView)findViewById(R.id.imageView);
        
Animation animZoomin = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_in);
        
imageView.startAnimation(animZoomin);

创建一个定义要执行的动画类型的 xml 文件。该文件应位于res 目录下的 anim 文件夹下 (res ⇒ anim ⇒ zoom_in.xml)。如果您的 res 目录中没有 anim 文件夹,请创建一个。

将以下代码放入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>
于 2013-10-25T09:10:07.260 回答
0

StackOverFlow 上似乎有一些类似的主题:

在android中放大和缩小动画

放大动画

这是 developer.android.com 上的一篇文章:

http://developer.android.com/training/animation/zoom.html

希望有帮助。:]

于 2013-10-25T08:11:55.647 回答