可绘制围绕其中心机器人 [英] Drawable Rotating around its center Android

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

问题描述

我正奇怪的结果有以下code:

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);

请告诉我正确的方式来指定轴点(绘制中心)?

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);

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

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