1. Table Layout
테이블 레이아웃은 격자 모양으로 뷰를 배치할 때 사용한다.
리니어 레이아웃 안에 리니어 레이아웃을 넣는 방식을 사용해도 격자 모양을 만들 수 있지만 테이블 레이아웃을 사용하면 좀 더 쉽게 만들 수 있다.
테이블 레이아웃에서 각각의 행은 <TableRow> 태그를 이용해 추가할 수 있다.
그리고 그 안에 몇 개의 뷰를 추가하는가에 따라 열의 개수가 결정된다.
여러 개의 <TableRow>가 추가될 수 있고 각각의 <TableRow> 안에는 여러 개의 뷰가 들어갈 수 있는 구조로 되어 있다.
2. 결과 화면
3. activity_main.xml
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 | <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="com.tistory.qlyh8.pracitice.MainActivity" android:stretchColumns="0,1,2" android:layout_margin="10dp"> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="이름 : " /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_span="2"/> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="아니오" android:layout_column="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="예" android:layout_column="2"/> </TableRow> </TableLayout> | cs |
출처: https://www.edwith.org/boostcourse-android/lecture/17050/
'Android' 카테고리의 다른 글
Event (이벤트) (0) | 2018.04.28 |
---|---|
ScrollView (스크롤뷰) (0) | 2018.04.28 |
Drawable (드로어블) - Shape Drawable (0) | 2018.04.28 |
Drawable (드로어블) - StateListDrawable (0) | 2018.04.27 |
Drawable (드로어블) (0) | 2018.04.27 |