均匀地缩放线性布局中的图像

时间:2010-09-25 21:47:52

标签: android layout imageview android-linearlayout

我的线性布局包含6个图像,这些图像水平跨越线性布局。

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@layout/roundedcorner">
        <ImageView
          android:id="@+id/Icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/someImage">
        </ImageView>
        ...

问题是,前5个图像不缩放并取其像素宽度,第6个图像被缩小,因为水平方向没有足够的空间。

有没有办法缩小所有图像,使它们看起来一致?

1 个答案:

答案 0 :(得分:4)

android:layout_weight="1"添加到每个ImageView。如果图像大小相同,那么它们将以相同的方式缩放。