zoomin.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="20000" androID:fromXScale="1" androID:fromYScale="1" androID:pivotX="50%" androID:pivotY="50%" androID:toXScale="3" androID:toYScale="3" > </scale></set>
zoomout.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="20000" androID:fromXScale="1.0" androID:fromYScale="1.0" androID:pivotX="50%" androID:pivotY="50%" androID:toXScale="0.5" androID:toYScale="0.5" > </scale></set>
和我的Activity类:
Animation zoomin,zoomout; //declared as public@OverrIDepublic voID onCreate(Bundle savedInstanceState) { // animation zoomin = AnimationUtils.loadAnimation(this,R.anim.zoomin); zoomout = AnimationUtils.loadAnimation(this,R.anim.zoomout); bgImage.setAnimation(zoomin); bgImage.setAnimation(zoomout); Thread t = new Thread(new Zoom()); t.start();}private class Zoom implements Runnable { @OverrIDe public voID run() { while (true) { bgImage.startAnimation(zoomin); try { Thread.sleep(8000); } catch (InterruptedException e) { e.printstacktrace(); } bgImage.startAnimation(zoomout); } }}
这里的zoomin动画似乎工作正常.有没有办法连续实现缩放和缩小动画?
谢谢
解决方法 使用这个而不是线程zoomin.setAnimationListener(new AnimationListener() { @OverrIDe public voID onAnimationStart(Animation arg0) { // Todo auto-generated method stub } @OverrIDe public voID onAnimationRepeat(Animation arg0) { // Todo auto-generated method stub } @OverrIDe public voID onAnimationEnd(Animation arg0) { bgImage.startAnimation(zoomout); } });
和
zoomout.setAnimationListener(new AnimationListener() { @OverrIDe public voID onAnimationStart(Animation arg0) { // Todo auto-generated method stub } @OverrIDe public voID onAnimationRepeat(Animation arg0) { // Todo auto-generated method stub } @OverrIDe public voID onAnimationEnd(Animation arg0) { bgImage.startAnimation(zoomin); } });总结
以上是内存溢出为你收集整理的Android ImageView连续放大和缩小全部内容,希望文章能够帮你解决Android ImageView连续放大和缩小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)