Android 앱 개발 중 사용자로부터 필요한 정보를 입력받아야 하는 경우가 있다. (거의 항상)
아래와 같은 유형의 화면 구성을 하고자 할 때에는
TableLayout을 유용하게 사용할 수 있다.
사용법은 간단하다.
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 여기에 원하는 view를 추가하면 하나의 Row에 보여지게 된다. -->
</TableRow>
</TableLayout>
| cs |
코드 예제
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
55
56
57
58
59
60
61
62
63
64
65
66
|
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/new_account_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvNewAccountName"
android:layout_weight="1"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="New Bank Account Name"
android:ems="10"
android:id="@+id/etNewBankAccountName"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/current_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvCurrentBalance"
android:layout_weight="1"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberSigned"
android:ems="10"
android:id="@+id/etCurrentBalance"
android:layout_weight="1"
android:hint="1,000,000"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/account_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvAccountNumber"
android:layout_weight="1"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberSigned"
android:ems="10"
android:id="@+id/etAccountNumber"
android:layout_weight="1"
android:singleLine="false"
android:selectAllOnFocus="false"
android:hint="110-123-456789"/>
</TableRow>
</TableLayout>
| cs |
위 코드의 결과로 아래와 같이 정렬된 화면을 볼 수 있다.
Top 5 casino games at JtHub - JtmHub
답글삭제The top 5 casinos in 아산 출장마사지 New 경상남도 출장마사지 Jersey offer 익산 출장샵 the best gaming experience, from slots to blackjack. 김천 출장샵 Visit our online 상주 출장샵 casino today!