【发布时间】:2015-09-30 19:58:47
【问题描述】:
我尝试使用RelativeLayout 将图像覆盖在另一个图像上,但出现了不必要的空白。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#263238"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp"
android:gravity="top">
<ImageView
android:id="@+id/heroImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/test3"
android:layout_alignParentTop="true"
android:scaleType="fitStart" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/corner" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:id="@+id/linearlayout_hero">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance"/>
</LinearLayout>
你可以在Wolverine的图片和文字之间看到它。
【问题讨论】:
-
您能定义“不必要的空白空间”是什么意思吗?您提供了 12dp 的填充,并且您的图像的宽高比与其所在的帧不同。使图像适合空间的唯一方法是拉伸或剪裁左右两侧。
标签: android android-layout android-imageview android-relativelayout