2

我有 4 个水平放置在 LinearLayout 中的 ImageView。我需要两件事:

  1. 如果空间受限于它们的高度,我希望它们在 LinearLayout 上均匀分布,即彼此之间的空间相等
  2. 如果空间受到宽度的限制,我希望图像缩小,以便它们都适合视图。

有任何想法吗?谢谢!

4

1 回答 1

4

你可以试试weightSum

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:orientation="horizontal"
        android:weightSum="4">
        <!-- Put your imageViews here and set android:layout_weight="1" each -->
</LinearLayout>

您还可以设置 minHeight 和 minWidth

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="20dp"
            android:minWidth="20dp"
    ></LinearLayout>
于 2012-05-03T01:22:07.190 回答