0
在不同的Android版本中旋轉內部具有圖像視圖的佈局(例如FrameLayout)時出現奇怪的行爲。Android 4.3之前的佈局旋轉和裁剪行爲
在下面這段XML佈局看看:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<FrameLayout
android:layout_width="250dp"
android:layout_height="250dp"
android:background="#ffffff"
android:layout_gravity="center"
android:rotation="15" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/bg" />
</FrameLayout>
</FrameLayout>
下面將在Android 4.3和4.4,但奇怪的結果顯示在Android 4.2,4.1,4.0.3良好的效果。
在Android 4.2(壞的結果)
在Android 4.3(好成績)
任何人都知道爲什麼出現這種情況到Android 4.3之前,如何解決它?
謝謝!
嘗試切換到從視圖動畫(基於屬性的動畫(http://developer.android.com/guide/topics/graphics/prop-animation.html)HTTP: //developer.android.com/guide/topics/graphics/view-animation.html)。我遇到了一些類似的問題,並通過此開關解決了問題。 – aga 2014-10-05 19:36:30
謝謝,但這不是動畫相關的。它只是一個靜態的佈局,我想旋轉一切。 – 2014-10-06 06:11:52
@TheGreatDescartes你在真實的設備上試過了嗎?可能是一個模擬器問題。你是否還試圖通過代碼設置它,或者實際上拋棄了內部FrameLayout,而只是旋轉imageView(或其內容)?這裏有一些方法來旋轉的東西:http://stackoverflow.com/questions/1930963/rotating-a-view-in-android。順便說一句,關於動畫,從Honeycomb開始,這實際上是動畫的工作原理:旋轉字段的值隨着動畫運行而改變,並且它們都被同步。 – 2014-10-08 11:43:59