问题描述
imageView.SetRotation(THETA)centerize绕枢轴点的观点,并绕这个支点由2θ角的形象,那是不错,但我怎么能旋转图像视图没有先centerizing它解决这个支点?
imageView.SetRotation(theta) centerize the view around the pivot point and rotates the image around this pivot by theta degrees, thats nice, but how can i rotate an image view without first centerizing it around this pivot?
要clearify我的问题,试想一个电路板,并在其上的图像,什么setRotation确实是坚持一个引脚采用了图像的中间,并将其旋转的话,我想是要挑一个支点 - 比如图像的左下方贴一个脚那里,然后将其旋转。
to clearify my question, imagine a board and an image on it, what setRotation does is sticking a pin in the middle of this image and rotate it then, what i want is to pick a pivot - say image's bottom left stick a pin there and then rotate it.
希望我的问题是清楚的,solveable!
hopefully my question is clear, and solveable!
谢谢!
推荐答案
您可以通过设置一个新的支点:
You can set a new pivot point using:
setPivotY(float pivotY);
setPivotX(float pivotX);
在此之后,该旋转将被使用新的枢转点通过上述方法设定制成
After that, the rotation will be made using the new pivot point set by the above methods.
- EDITED -
--EDITED--
我用这个方法来添加一个的ImageView
来我的布局。
I used this method to add a ImageView
to my layout.
private ImageView addImageView(RelativeLayout mainLayout, int x, int y, int width, int height, OnClickListener onClickListener){
ImageView imageView = new ImageView(this);
imageView.setAdjustViewBounds(false);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.height = height;
params.width = width;
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setImageDrawable(getResources().getDrawable(R.drawable.marker_red));
params.leftMargin = x - width/2;
params.topMargin = y - height/2;
imageView.setOnClickListener(onClickListener);
mainLayout.addView(imageView);
return imageView;
}
我所谓的方法与此参数:
I called the method with this parameters:
ImageView imageView;
imageView = addImageView(mainLayout, 200, 300, 200, 200, new OnClickListener() {
@Override
public void onClick(View v) {
imageView.setPivotX(200);
imageView.setPivotY(200);
imageView.setRotation(45);
}
});
最后,你只需点击图像,图像旋转45度。
Finally, you just click on the image, and the image rotates 45 degrees.
关于
这篇关于图像视图定制旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!