In this part of the tutorial we look at how to setup the layout file for our main activity. Next in the series we will look at how to tie together our layout with the previous java code we wrote for the "behind the scenes" work by coding our main activity.
Let me know what you think. As always if you notice an error or something that could be done differently to improve this tutorial let me know.
Files to go with this tutorial:
main.xml
1: <?xml version="1.0" encoding="utf-8"?>
2: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3: android:layout_width="fill_parent"
4: android:layout_height="fill_parent"
5: android:orientation="vertical" >
6:
7: <TableLayout
8: android:id="@+id/playArea"
9: android:layout_width="match_parent"
10: android:layout_height="wrap_content"
11: android:layout_marginTop="10dp" >
12:
13: <TableRow
14: android:id="@+id/tableRow1"
15: android:layout_width="wrap_content"
16: android:layout_height="wrap_content"
17: android:gravity="center_horizontal" >
18:
19: <Button
20: android:id="@+id/one"
21: android:layout_width="100dp"
22: android:layout_height="100dp"
23: android:text="@string/one"
24: android:textSize="70dp" />
25:
26: <Button
27: android:id="@+id/two"
28: android:layout_width="100dp"
29: android:layout_height="100dp"
30: android:text="@string/two"
31: android:textSize="70dp" />
32:
33: <Button
34: android:id="@+id/three"
35: android:layout_width="100dp"
36: android:layout_height="100dp"
37: android:text="@string/three"
38: android:textSize="70dp" />
39: </TableRow>
40:
41: <TableRow
42: android:id="@+id/tableRow2"
43: android:layout_width="wrap_content"
44: android:layout_height="wrap_content"
45: android:gravity="center_horizontal" >
46:
47: <Button
48: android:id="@+id/four"
49: android:layout_width="100dp"
50: android:layout_height="100dp"
51: android:text="@string/four"
52: android:textSize="70dp" />
53:
54: <Button
55: android:id="@+id/five"
56: android:layout_width="100dp"
57: android:layout_height="100dp"
58: android:text="@string/five"
59: android:textSize="70dp" />
60:
61: <Button
62: android:id="@+id/six"
63: android:layout_width="100dp"
64: android:layout_height="100dp"
65: android:text="@string/six"
66: android:textSize="70dp" />
67: </TableRow>
68:
69: <TableRow
70: android:id="@+id/tableRow3"
71: android:layout_width="wrap_content"
72: android:layout_height="wrap_content"
73: android:gravity="center_horizontal" >
74:
75: <Button
76: android:id="@+id/seven"
77: android:layout_width="100dp"
78: android:layout_height="100dp"
79: android:text="@string/seven"
80: android:textSize="70dp" />
81:
82: <Button
83: android:id="@+id/eight"
84: android:layout_width="100dp"
85: android:layout_height="100dp"
86: android:text="@string/eight"
87: android:textSize="70dp" />
88:
89: <Button
90: android:id="@+id/nine"
91: android:layout_width="100dp"
92: android:layout_height="100dp"
93: android:text="@string/nine"
94: android:textSize="70dp" />
95: </TableRow>
96: </TableLayout>
97:
98: <TextView
99: android:id="@+id/information"
100: android:layout_width="match_parent"
101: android:layout_height="wrap_content"
102: android:layout_marginTop="5dp"
103: android:gravity="center_horizontal"
104: android:text="@string/info"
105: android:textSize="25dp" />
106:
107: <TableLayout
108: android:id="@+id/tableLayout1"
109: android:layout_width="match_parent"
110: android:layout_height="wrap_content" >
111:
112: <TableRow
113: android:id="@+id/tableRow4"
114: android:layout_width="wrap_content"
115: android:layout_height="wrap_content"
116: android:layout_marginTop="10dp"
117: android:gravity="center_horizontal" >
118:
119: <TextView
120: android:id="@+id/human"
121: android:layout_width="wrap_content"
122: android:layout_height="wrap_content"
123: android:text="@string/human" />
124:
125: <TextView
126: android:id="@+id/humanCount"
127: android:layout_width="wrap_content"
128: android:layout_height="wrap_content"
129: android:layout_marginRight="10dp" />
130:
131: <TextView
132: android:id="@+id/ties"
133: android:layout_width="wrap_content"
134: android:layout_height="wrap_content"
135: android:text="@string/ties" />
136:
137: <TextView
138: android:id="@+id/tiesCount"
139: android:layout_width="wrap_content"
140: android:layout_height="wrap_content"
141: android:layout_marginRight="10dp" />
142:
143: <TextView
144: android:id="@+id/android"
145: android:layout_width="wrap_content"
146: android:layout_height="wrap_content"
147: android:text="@string/android" />
148:
149: <TextView
150: android:id="@+id/androidCount"
151: android:layout_width="wrap_content"
152: android:layout_height="wrap_content" />
153:
154: </TableRow>
155: </TableLayout>
156: </LinearLayout>
Check us out on Google+ (Indie Development).
Check us out on our .co site (Indie Development).
No comments:
Post a Comment