我有一个围绕任意点旋转的图像。但我需要 3 个这样的图像同时旋转这就是我尝试实现相同的方式
private void rotateLogo(float degrees){
Matrix matrix1 = new Matrix();
//int radius = turntable.getWidth()/2;
double radians = degrees* (Math.PI/180);
double xcoordinate = 220 * Math.cos(radians)- 60;
double ycoordinate = 220 * Math.sin(radians) + 50;
matrix1.postRotate((int)radians, 220, 220);
// people image
FrameLayout.LayoutParams linLay = (FrameLayout.LayoutParams) peopleLogo.getLayoutParams();
linLay.bottomMargin = (int)ycoordinate + 10;
linLay.rightMargin = (int)xcoordinate + 10;
peopleLogo.setImageMatrix(matrix1);
peopleLogo.setLayoutParams(linLay);
rotateLogo2(degrees - 2);
}
private void rotateLogo2(float degrees){
double radians = degrees* (Math.PI/180);
double xcoordinate = 220 * Math.cos(radians)- 60;
double ycoordinate = 220 * Math.sin(radians) + 50;
// people image
FrameLayout.LayoutParams linLay = (FrameLayout.LayoutParams) serverLogo.getLayoutParams();
linLay.bottomMargin = (int)ycoordinate + 10;
linLay.rightMargin = (int)xcoordinate + 10;
serverLogo.setLayoutParams(linLay);
}
在上面的代码中,我减少了角度并使用相同的代码旋转了第二张图像,但图像不旋转,它只是在触摸时消失。
我还尝试在旋转之前获取第一张图像的布局参数并将其应用于第二张图像,但这也不起作用..
图像在旋转时消失,但有时它会出现然后消失
任何人都可以帮助我了解我可能错在哪里或提出任何其他相同的方法吗?