Android layout 如何将ImageView设置为以相等间距填充线性布局?
我有四个图像图标,我需要与Imagebutton或Imageview一起显示。问题是当我使用下面的代码时,它们都是左对齐的,在右边留下一个空白Android layout 如何将ImageView设置为以相等间距填充线性布局?,android-layout,Android Layout,我有四个图像图标,我需要与Imagebutton或Imageview一起显示。问题是当我使用下面的代码时,它们都是左对齐的,在右边留下一个空白 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="4"&g
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="@drawable/sale"
android:layout_weight="1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="@drawable/shirt"
android:layout_weight="1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="@drawable/women"
android:layout_weight="1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="@drawable/technology"
android:layout_weight="1"/>
</LinearLayout>
如何使它们在线性布局上均匀分布,从而填充整个宽度?我刚刚解决了这个问题。似乎我需要使用
android:layout\u width“fill\u parent”
而不是android:layout\u width=“wrap\u content”。
在@grwww建议android:layout\u gravity=“fill”
之后,我尝试了这个方法,但它不是必需的属性。然后我开始学习如何填写家长