[英]Scaling Images in a Linear Layout Evenly
I have a linear layout that contains 6 images, which span the linear layout horizontally. 我有一个包含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>
...
The problem is, the first 5 images do not scale and take their pixel width, and the 6th images is scrunched down, because there is not enough space left horizontally. 问题是,前5张图像无法缩放并占据其像素宽度,而第6张图像则缩小了,因为水平方向上没有足够的空间。
Is there a way to scale all the images down so they have a uniform look? 有没有办法按比例缩小所有图像,使它们具有统一的外观?
Add android:layout_weight="1"
to each ImageView. 将
android:layout_weight="1"
到每个ImageView。 If images are of equal size, they will be scaled in the same way then. 如果图像大小相等,则将以相同的方式缩放图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.