0
我想旋轉一個ImageView,以特定的角度和特殊的程度。我在谷歌搜索並找到了一些解決方案,但我沒有找到完整的答案(如this answer)。在API 10中旋轉Android ImageView(不使用動畫)
我試過用這個代碼,但是ImageView
沒有旋轉!只是它的背景旋轉(不旋轉視圖矩形)
public class ImageViewCustom extends ImageView {
public Context M_context;
public ImageViewCustom(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.M_context = context;
}
public ImageViewCustom(Context context, AttributeSet attrs) {
super(context, attrs);
this.M_context = context;
}
public ImageViewCustom(Context context) {
super(context);
this.M_context = context;
}
public float xPivot;
public float yPivot;
public float degree;
public void draw(Canvas canvas) {
canvas.save();
canvas.rotate(degree, xPivot, yPivot);
super.draw(canvas);
canvas.restore();
}
}
所以,我怎麼能旋轉的ImageView不使用Animation
,只是用覆蓋或添加旋轉的方法來ImageViewCustom
?
感謝提前:)
它只是旋轉ImageView的背景,而不是ImageView。 –
是真實的,但根據您的需求,它可能是高效的,只是試圖幫助 – ePeace
非常感謝:) –