【发布时间】:2014-02-02 03:57:59
【问题描述】:
我正在尝试创建一个始终显示 2 个图像的布局,将屏幕长度平均分成两半,屏幕上不留空白(即使图像被中心裁剪)。
到目前为止,我有以下代码,但这会在屏幕底部留下很多空白区域。我在“LinearLayout”中使用“RelativeLayout”的原因是因为我希望我的 text1 视图位于图像 1 的下部(与图像 1 重叠)。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_marginBottom="3dp" >
<ImageView
android:id="@+id/img1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:contentDescription="@string/picture"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:padding="5dp"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_marginBottom="3dp" >
<ImageView
android:id="@+id/img2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:contentDescription="@string/picture"
android:scaleType="centerCrop" />
</RelativeLayout>
【问题讨论】:
标签: android css android-layout