행과 열로 구성된 테이블 화면을 만드는 레이아웃 클래스이다.
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:columnCount="3">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:layout_gravity="fill_horizontal"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:layout_row="1"
android:layout_column="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="D"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EFGHIJKLMNOPQRSTUVWXYZ"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RIGHT"
android:layout_row="1"
android:layout_column="0"
android:layout_gravity="right" />
</GridLayout>
orientation
속성을 통해 방향을 결정한다."vertical"
: 세로 배치rowCount
속성값으로 줄바꿈"horizontal"
: 가로 배치columnCount
속성값으로 줄바꿈 layout_row
: 세로 인덱스layout_column
: 가로 인덱스layout_gravity
속성을 통해 해당 칸 내의 뷰 배치를 변경 할 수 있다."fill_horizontal"
: 인덱스 여백 채우기"right"
: 해당 칸의 오른쪽 배치layout_columnSpan
: 가로 열 병합layout_rowSpan
: 세로 열 병합(XML 레이아웃 미리보기)