我需要做一个布局,其中 4 个图像使用 XML 以不同大小显示在一个框中。
该框是一个线性布局,高度固定为300dp,宽度为fill_parent。不需要使用 LinearLayout 来执行此操作。
我尝试使用权重和权重来做到这一点,但没有成功。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_margin="10dp" >
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/image1" />
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/image2" />
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:src="@drawable/image3" />
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:src="@drawable/image4" />
</LinearLayout>