大佬教程收集整理的这篇文章主要介绍了android-animation – 用于放大和缩小android for imageview的动画,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
第一种方式:
在res中创建一个名为’anim’的新文件夹.比在里面创建一个xml文件,例如zoomin.xml.然后将以下代码放入其中.
<scale xmlns:android="http://scheR_241_11845@as.android.com/apk/res/android" android:fromXScale="1" android:toXScale="5" android:fromYScale="1" android:toYScale="5" android:pivotX="50%" android:pivotY="50%" android:duration="1000" android:fillAfter="true"> </scale>
另一个用于缩小,但具有反转值.
<scale xmlns:android="http://scheR_241_11845@as.android.com/apk/res/android" android:fromXScale="5" android:toXScale="1" android:fromYScale="5" android:toYScale="1" android:pivotX="50%" android:pivotY="50%" android:duration="1000" android:fillAfter="true"> </scale>
您可以根据需要更改值.我认为它们是不言自明的.
ImageView imageView = (imageView)findViewById(R.id.yourImageViewId); Animation zoomin = AnimationUtils.loadAnimation(this,R.anim.zoomin); Animation zoomout = AnimationUtils.loadAnimation(this,R.anim.zoomout); imageView.setAnimation(zoomin); imageView.setAnimation(zoomout);
现在你只需要跟踪哪个是当前状态.并为每个州执行以下代码行:
imageView.startAnimation(zoomin);
和
imageView.startAnimation(zoomout);
例如:
imageView.setOnClickListener(new OnClickListener(){ public void onClick(View v) { if(!pressed) { v.startAnimation(zoomin); pressed = !pressed; } else { v.startAnimation(zoomout); pressed = !pressed; } } });
另一种方式在这里描述:http://developer.android.com/training/animation/zoom.html.
以上是大佬教程为你收集整理的android-animation – 用于放大和缩小android for imageview的动画全部内容,希望文章能够帮你解决android-animation – 用于放大和缩小android for imageview的动画所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。