您必須使用重量:
例如
<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