您必须使用重量:
例如
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"/>
</LinearLayout>
到重量分布是很重要的。
如果你把10的总重量必须是10
如果你把3-3的总重量必须在3。
换句话说1 + 1 + 1 = 3所以处理3个元素的宽度。
或3.3 + 3.3 + 3.3 = 9.9
如果您不想留下空白空间,也可以避免使用weightSum。 –
是的,你是对的。 – josedlujan
感谢您的回答!那么,如果不使用weightSum,我只是相应地使用weigth? – Kanellis