안드로이드 앱 만들기

Linear Layout (2)

khon98 2020. 10. 6. 22:29

weightSum - 뷰의 높이 너비를 비율로 설정할 수 있게 해 줌 (단, orientation이 vertical인 경우 높이만 가능하고, horizontal의 경우 너비만 가능)

 

----------------------------------------

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="9">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="1"
        android:textSize="20sp"
        android:layout_weight="3">

    </TextView>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="2"
        android:layout_weight="3">

    </TextView>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="3"
        android:textSize="20sp"
        android:layout_weight="3">

    </TextView>

</LinearLayout>

----------------------------------------