Hello, Views >
Linear Layout
# LinearLayout
- 안드로이드 화면에 출력할때 쓰이는 방식중 하나 입니다. LinearLayout이라하며
한줄한줄 쓰이는 방식인데, 가로방향 세로방향으로 안보이는 이블을 생성합니다.
android:orientation="vertical" <-이곳의 vertical이 가로를 나타내고
android:orientation="horizontal" <-이곳의 horizontal이 세로를 나타냅니다.
# TextView
하나의 테이블을 의미한다고 생각하면 됩니다.
아래 소스는 하나의 리니어 레이아웃에 2개의 리니어 레이아웃이 삽입된 상태로
vertical설정 레이아웃 속에 윗쪽 레이아웃은 horizontal방식으로 아래쪽은 vertical방식으로
설정 되어 있음을 알 수 있습니다.
android:layout_width="fill_parent"
android:layout_width="wrap_content"
두줄의 소스의 차이는 fill_parent와 warp_content인데 fill_parent같은 경우는 한줄에 문자열이
입력된다면 문자열의 끝까지 공백으로 채워서 horizontal로 리니어 레이아웃이 설정되어있다면
두번째 textview가 보이지 않게 됩니다. wrap_content로 설정되면 공백이 아니라 문자열이
입력된곳까지만 설정되어 뒤에 두번째 textview까지 보이게 됩니다.
# 스크린샷
# 소스코드
res/layout/main.xml 이곳에 붙여넣기
Linear Layout
이글은 http://developer.android.com/ 의 튜토리얼을
제 나름대로 정리한 글입니다. 주관적이고 잘못된
요소가 들어 있을 수 있습니다.
# LinearLayout
- 안드로이드 화면에 출력할때 쓰이는 방식중 하나 입니다. LinearLayout이라하며
한줄한줄 쓰이는 방식인데, 가로방향 세로방향으로 안보이는 이블을 생성합니다.
android:orientation="vertical" <-이곳의 vertical이 가로를 나타내고
android:orientation="horizontal" <-이곳의 horizontal이 세로를 나타냅니다.
# TextView
하나의 테이블을 의미한다고 생각하면 됩니다.
아래 소스는 하나의 리니어 레이아웃에 2개의 리니어 레이아웃이 삽입된 상태로
vertical설정 레이아웃 속에 윗쪽 레이아웃은 horizontal방식으로 아래쪽은 vertical방식으로
설정 되어 있음을 알 수 있습니다.
android:layout_width="fill_parent"
android:layout_width="wrap_content"
두줄의 소스의 차이는 fill_parent와 warp_content인데 fill_parent같은 경우는 한줄에 문자열이
입력된다면 문자열의 끝까지 공백으로 채워서 horizontal로 리니어 레이아웃이 설정되어있다면
두번째 textview가 보이지 않게 됩니다. wrap_content로 설정되면 공백이 아니라 문자열이
입력된곳까지만 설정되어 뒤에 두번째 textview까지 보이게 됩니다.
# 스크린샷
# 소스코드
res/layout/main.xml 이곳에 붙여넣기
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="red"
android:gravity="center_horizontal"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="green"
android:gravity="center_horizontal"
android:background="#00aa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="blue"
android:gravity="center_horizontal"
android:background="#0000aa"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="yellow"
android:gravity="center_horizontal"
android:background="#aaaa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="row one"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row two"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row three"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row four"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>