Android/기본

Android LinearLayout 가중치

Bohemian life 2012. 4. 28. 19:34

가중치(Weight)

배치할때 View의 비율을 정해줌


보통 2개를 비교해 가중치를 준다.

0(최소),1(최대)


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

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Tool_Bar"
        android:layout_weight="0"
         />
    
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
    
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Menu_Bar"
        android:layout_weight="0" />

</LinearLayout>