android:weightSum
이 필수인지 여부는 android:layout_weight
일까요? 없이 android:layout_weight
을 linearlayout
내부에 직접 사용할 수 있습니까? 누구든지 android:layout_weight
을 사용하고, android:weightSum
을 사용하지 않고 장단점을 말해주십시오. 미리 감사드립니다.안드로이드를 추가하지 않고 android : layout_weight를 사용할 수 있습니까? 그렇다면 문제는 무엇입니까?
샘플 코드 : 부모에게 weightSum : 안드로이드를 추가하지 않고에 layout_weight :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/table_view"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:orientation="horizontal">
<Button
android:id="@+id/button_1"
style="@style/BaseButtonStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/start" />
<Button
android:id="@+id/button_2"
style="@style/BaseButtonStyle"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_weight="1"
android:text="@string/pause"
android:textColor="@color/teal" />
<Button
android:id="@+id/button_3"
style="@style/BaseButtonStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stop" />
</LinearLayout>
내 생각에 LinearLayout이 weighSum 속성을 설정하지 않습니다. 그러나 아이들은 같은 가중치 또는 다른 가중치를 가진 android : layout_weight을 가지고 있습니다. 귀하의 예에서는 오직 한 명의 자녀가 android : layout_weight를 가지고 있습니다. 모든 아이는 체중을가집니다. LinearLayout에는 체중이 없습니다 .Sum. – Praveen2Gemini
다중 가중치를 사용하는 경우 시스템이 측정 할 수 있도록 'weightSum'을 정의해야합니다. 상위 (사례)에 따라 높이 또는 너비를 측정합니다. 한 아이를 갖기를 원할 때, 특정 아이에게 체중을 사용하면 나머지 아이가 자동으로 자신의 차원을 차지하게됩니다 (나의 경우). – Wizard