我旋转了一个转盘围绕它的中心与帮助从下面的链接:
http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-rotating-dialer/
现在,我在拨号器旁边有一个图标,我需要把它围绕着拨号器旋转,同时在一个圆形的路径上旋转它。
private void rotateLogo(float degrees){
Matrix nMatrix = new Matrix();
Bitmap peopleOrg = BitmapFactory.decodeResource(getResources(), R.drawable.peoplelogo);
float translateX = dialerWidth / 2 - dialerWidth / 2;
float translateY = dialerHeight / 2 - dialerWidth / 2;
nMatrix.preTranslate(-turntable.getWidth()/2, -turntable.getHeight()/2);
nMatrix.postRotate(degrees, translateX, translateY);
nMatrix.postTranslate(turntable.getWidth()/2, turntable.getHeight()/2);
Bitmap peopleScale = Bitmap.createBitmap(peopleOrg, 0, 0, peopleOrg.getWidth(), peopleOrg.getHeight(), nMatrix, true);
peopleLogo.setImageBitmap(peopleScale);
peopleLogo.setImageMatrix(nMatrix);
}这只会使图像围绕自己的中心旋转,而不是围绕拨号器的中心点旋转。我找不出我哪里错了。
更新
旋转相同的帮助。
发布于 2012-06-19 12:02:56
尝试只旋转与peopleOrg宽度和高度。
nMatrix.postRotate(degrees, peopleOrg.getWidth()/2, peopleOrg.getHeight()/2);更新:
现在你让我知道你的标志应该是一个可点击的视图,合并标志图像和你的拨号是不适用的。要在拨号器中心旋转徽标视图,您应该实际计算徽标视图的(上、左)点,并移动它,而不仅仅是旋转它。
使用 cosine 和cosine函数来获取虚拟圆周上的点,以绘制徽标视图。
这篇文章将帮助你进行计算:How do I calculate a point on a circle’s circumference?
https://stackoverflow.com/questions/11099814
复制相似问题