안드로이드 어플리케이션에서 RelativeLayout 다음으로 많이 사용하는 레이아웃이다. 안드로이드스튜디오는 이외에도 여러 레이아웃을 제공하지만 사실상 RelativeLayout, LinearLayout 두 가지면 거의 충분하다.
웹사이트처럼 레이아웃을 나누는 예제이다. Layout의 넓이, 높이 그리고 orientation 기능으로 여러 가지 실험을 하다 코드가 조금 지저분한 경향이 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <?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"> <LinearLayout android:id="@+id/lay1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <LinearLayout android:id="@+id/lay3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="#ff0011"> </LinearLayout> <LinearLayout android:id="@+id/lay4" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <LinearLayout android:id="@+id/lay5" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="#11ff00"> </LinearLayout> <LinearLayout android:id="@+id/lay6" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="#fff700"> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/lay2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#00ccff"> </LinearLayout> </LinearLayout> | cs |
'문돌이의 IT > 안드로이드' 카테고리의 다른 글
안드로이드(Android) 화면 가로 세로 전환하기 (0) | 2016.05.28 |
---|---|
안드로이드스튜디오 어댑터뷰어(adapter viewer) ListView GridView Spinner (0) | 2016.05.27 |
안드로이드 RelativeLayout 예제(2) (0) | 2016.05.24 |
안드로이드 RelativeLayout 예제(1) (0) | 2016.05.22 |
베가 통합USB드라이버 다운로드 (0) | 2016.05.21 |