简体   繁体   English

从特定的“旋转点”旋转可绘制对象

[英]Rotate drawable from a specific “rotation point”

I have an image, a simple black rectangle. 我有一个图像,一个简单的黑色矩形。 I want to be able to rotate the image from a specific rotation point in it, with a certain amount of degrees provided by the user in a textbox(all this done, keeping the location intact). 我希望能够从文本框中的特定旋转点旋转图像,并在文本框中由用户提供一定程度的角度(所有这些操作都已完成,保持位置不变)。

illustration of "rotation point" “旋转点”的插图

ImageView has 2 fields that keep coordinates of a pivot point. ImageView有2个字段,用于保留枢轴点的坐标。 In your case, only one of them needs to change and that is X coordinate. 在您的情况下,只需更改其中一个,即X坐标。 Here is the working example: 这是工作示例:

imageView.setPivotX(0);
imageView.setRotation(DEGREES);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM