我基本上是在尝试实现类似于this的东西。不幸的是,这是一个iOS教程。
我已经在谷歌上搜索了最可能的关键字,以循环的方式移动一些东西,但找不到任何开始。有没有人至少能提供一些关于如何在android上破解这一点的提示?请。
谢谢。
发布于 2012-05-17 04:04:37
在自定义控件中很容易做到这一点。只需创建一个扩展View的类并覆盖draw()方法。然后,您可以监听触摸并计算用户旋转控件的距离。然后,您只需要使用这些数据来旋转画布并在上面绘制数字。
画布更新=-当你重写-=方法时,你会得到一个画布对象。这个对象让你想画什么就画什么。它看起来像这样:
@Override
public void draw(Canvas c)
{
c.rotate(amount);
c.drawBitmap(myImage);
}这是指向完整Canvas Documentation的链接。
发布于 2012-05-21 12:53:25
我使用旋转动画来围绕一个点旋转图像。
double r = Math.atan2(evt.getX() - turntable.getWidth() / 2, turntable.getHeight() / 2 - evt.getY());
rotation = (int) Math.toDegrees(r);
if (evt.getAction() == MotionEvent.ACTION_MOVE)
{
x= (int)evt.getX();
y = (int)evt.getY();
rotateAnim = new RotateAnimation(angle,rotation-50,200,100);
rotateAnim.setFillAfter(true);
ImageView.setanimation(rotateAnim );
ImageView.startAnimation(rotateAnim);
}您还可以使用矩阵
float newRot = new Float(rot);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.disc);
Matrix matrix = new Matrix();
matrix.postRotate(newRot - 50);
Bitmap redrawnBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
turntable.setImageBitmap(redrawnBitmap); https://stackoverflow.com/questions/10625587
复制相似问题