상세 컨텐츠

본문 제목

안드로이드 레이아웃 left, right, top, bottom 기준으로 먼저 영역을 잡은뒤 fill_parent 으로 채우기, weight로 필요영역 남기고 채우기

스마트기기개발관련/안드로이드 개발

by AlrepondTech 2012. 3. 13. 11:04

본문

반응형

 

 

 

 

=================================

=================================

=================================

 

 

 

 

 

// 오른쪽 기준으로 먼저 잡고 그다음에 fill_parent 모든 영역을 잡는다.
//----------------------------------------------
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="right"
 android:adjustViewBounds = "true"
 >
  
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="100dip"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>
 </LinearLayout>



// 왼쪽 기준으로 먼저 잡고 그다음에 fill_parent 모든 영역을 잡는다.
//----------------------------------------------------
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="left"
 android:adjustViewBounds = "true"
 >
  
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="100dip"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>
 </LinearLayout>


// 탑 top 기준으로 먼저 잡고 그다음에 fill_parent 모든 영역을 잡는다.
//-----------------------------------------------------
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="top"
 android:adjustViewBounds = "true"
 >
  
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="100dip"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>
 </LinearLayout>


// 봇 bottom 기준으로 먼저 잡고 그다음에 fill_parent 모든 영역을 잡는다.
//--------------------------------------------------
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="top"
 android:adjustViewBounds = "true"
 >
  
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="100dip"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>
 </LinearLayout>


// android:layout_weight 이용하여 영역 늘리기
//----------------------------------------------------------------

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="top"
 android:adjustViewBounds = "true"
 >
  
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="0"
 android:layout_weight = "1"  // fill 로 채우면서 밑에 영역이 있으면 다채우지않고 거기 까지만 제한한다.
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="100dip"
 android:adjustViewBounds = "true"
 android:background="#80ff0000"
 >
  </LinearLayout>
 </LinearLayout>

 

 

 

=================================

=================================

=================================

 

 

 

반응형


관련글 더보기

댓글 영역