我有一个要求,我必须旋转图像并堆叠3个图像在彼此之上。 如何在android中创建可堆叠的图像?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/rellay"
tools:context=".MainActivity" >
<com.example.stackableimages.ImageRotatedView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/square"
android:id="@+id/image" />
<com.example.stackableimages.ImageRotatedView2
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/square2"
android:id="@+id/image1" />
</RelativeLayout>
注意:它应该以杂乱无章的方式堆放。每次旋转的角度都不相同。旋转动画不是解决方案。我使用了三个图像浏览的相对布局。我是否需要创建自定义视图并覆盖onDraw方法
View.setRotation有助于实现此目的,但它在api 11之后可用。我的应用程序应该与api 7兼容。 我如何在android中实现这一点。使用上面的代码,即使我使用了相对布局,我也只能看到单个图像?
您需要一个FrameLayout才能工作。我目前在移动设备上,所以我不能发布代码,但谷歌肯定会帮助你与FrameLayouts – James