개발/안드로이드(Android-Kotlin)
레이아웃 절반 등분하기
----___<<<<<
2019. 6. 25. 01:45
안드로이드에서 레이아웃을 딱 맞춰서 절반 나누는 방법입니다.
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">
<LinearLayout
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="0dp">
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_width="0dp">
</LinearLayout>
</LinearLayout>
맨 위에 감싸는 LinearLayout 에 weightSum=""에 N등분 할지를 정해서
안에 들어가는 LinearLayout에 layout_weight="1"로 하면 1/N로 됩니다.
매우 간단합니다.