我需要在我正在处理的应用上创建指南针。所以我试图创建一个名为CompassView的新视图,该视图基本上扩展了imageview,显示了一个位于东南西北的位图,它使用传感器来查找手机指向的度数,并相应地旋转图像以创建它一个真正的指南针。但问题是如果我试图旋转图像到一些像45度的角度,它会缩小。这里有一些图像可以更好地解释它。旋转图像而不缩水在Android上
正如你所看到的,第二图像收缩下来的时候我尽量绕45.我希望它做的是这样的:
这里我正在使用的代码:
Bitmap bMap = BitmapFactory.decodeResource(getResources(),
R.drawable.compass);
Matrix xMatrix = new Matrix();
xMatrix.reset();
xMatrix.postRotate(360-mValue, 75, 75); //This is 75 because 150 is the image width
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,
bMap.getWidth(), bMap.getHeight(), xMatrix, true);
setImageBitmap(bMapRotate);
任何帮助将升值ated。 THANKs
编辑:(解决方案) 我终于得到它的工作得益于接受的答案。下面是我使用的人谁想要知道它是如何工作的代码:
RotateAnimation rAnimAntiClockWise = new RotateAnimation(
360 - mValue, 360 - event.values[0],
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
//mValue is the angle in degrees and i subtracted it from 360 to make it anticlockwise, and event.values[0] is the same thing as mValue
rAnimAntiClockWise.setFillAfter(true);
rAnimAntiClockWise.setInterpolator(new LinearInterpolator());
rAnimAntiClockWise.setDuration(0);
startAnimation(rAnimAntiClockWise);
非常感谢,我不知道,这可能是来达到的从旋转动画。我只需修改代码的某些部分即可运行 – KSubedi 2012-04-02 08:06:58