Android 自动调整imageView的大小
我有一个砖块图像,我正在尝试创建imageView的6x6表。 我尝试了很多方法将imageview设置为根据屏幕大小自动调整大小,但没有成功。 这是我的XML代码的一部分:Android 自动调整imageView的大小,android,imageview,android-xml,Android,Imageview,Android Xml,我有一个砖块图像,我正在尝试创建imageView的6x6表。 我尝试了很多方法将imageview设置为根据屏幕大小自动调整大小,但没有成功。 这是我的XML代码的一部分: <RelativeLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_below="@+id/relativeLayout" android:padd
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayout"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:gravity="center_vertical|center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_1"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_2"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_3"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />
</LinearLayout>
</RelativeLayout>
这就是我的结果:
我想要的是所有的图像视图将自动调整到相同的宽度和高度,并填充所有线性布局。我该怎么做 GridView更适合此任务。但您必须为此创建CustomAdapter。这肯定会解决你的问题。