我正在使用postRotate(float度,float px,float py)旋轉ImageView,將px和py設置爲幾個不同的值,包括(0,0)和(imgView.getHeight(),imgView.getWidth ()),但它拒絕圍繞中心以外的任何其他點旋轉。我想知道這是否與我的引力位於LinearLayout的中心有關?圍繞指定點旋轉圖像不起作用! (Android)
我的佈局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView
android:id="@+id/imageTraj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="matrix"
android:src="@drawable/impactangle" />
我是如何旋轉圖像:
matrix.postRotate(degrees,imageView.getHeight(),imageView.getWidth());
imageView.setImageBitmap(Bitmap.createBitmap(imageScaled, 0, 0,
imageScaled.getWidth(), imageScaled.getHeight(), matrix, true));
PS我注意到有一些類似的問題,但他們都沒有合適的答案。
謝謝,我現在就放棄這一點。 –
沒有。仍然拒絕圍繞中心以外的任何其他點旋轉。 –
哦,不!有用!我只需要調用setAngleRotation(顯然)。唯一的問題是,它會在原始邊界周圍剪切圖像。任何想法如何阻止它這樣做? –