안드로이드 스튜디오 전체/따라하기

안드로이드스튜디오 Linear Layout WeightSum 으로 배치하기

달톤 2020. 9. 3. 13:06
<?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="7">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:text="weight = 1"
        android:textSize="20sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#20000000"
        android:gravity="center"
        android:text="weight = 1"
        android:textSize="20sp" />

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

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.5"
        android:background="#20000000"
        android:gravity="center"
        android:text="weight = 1.5"
        android:textSize="20sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:gravity="center"
        android:text="weight = 0.5"
        android:textSize="20sp" />
</LinearLayout>

 

 weightSum = 7