Drawable 围绕其中心旋转 Android [英] Drawable Rotating around its center Android

查看:33
本文介绍了Drawable 围绕其中心旋转 Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下代码的奇怪结果:

I am getting strange results with the following code:

iv = (ImageView) findViewById(R.id.iv);
        iv.setImageResource(R.drawable.spinner_white_76);

        Animation a = new RotateAnimation(0.0f, 360.0f,
                Animation.RELATIVE_TO_SELF, iv.getDrawable()
                        .getIntrinsicWidth() / 2, Animation.RELATIVE_TO_SELF,
                iv.getDrawable().getIntrinsicHeight() / 2);
        a.setRepeatCount(-1);
        a.setDuration(1000);

        iv.startAnimation(a);

指定轴点(drawable的中心)的正确方法是什么?

Whats the right way to specify the axis point (center of the drawable)?

推荐答案

觉得自己很蠢!花一些时间仔细阅读文档后让它工作:

Feel stupid! Got it to work after spending some time closely reading the documentation:

Animation a = new RotateAnimation(0.0f, 360.0f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
        a.setRepeatCount(-1);
        a.setDuration(1000);

这篇关于Drawable 围绕其中心旋转 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆