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