嗯,我有 2 张图片,我想像这样显示。第二张图片应该位于第一张图片的右角。底部或顶部并不重要。
我正在尝试使用相对布局,但看起来不像这样
我想先用这个将取消图像放在图像底部
android:layout_alignParentBottom="true"
但它位于屏幕底部而不是图像底部。
最佳答案
您还可以使用框架布局来实现此目的,因为框架布局不需要任何关系,例如使用 android:layout_gravity="top|right"
属性:
<?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" >
<ImageView
android:id="@+id/image1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="top|right"
android:src="@drawable/ic_launcher" >
</ImageView>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:layout_below="@id/image1"
android:src="@drawable/ic_launcher" >
</ImageView>
</FrameLayout>
关于Android 相对布局图像叠加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22422079/