Skip to content

Commit ed22072

Browse files
committed
project #8: add 4 rows for buttons
1 parent 26f3e3a commit ed22072

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

Calculator/app/src/main/res/layout/activity_main.xml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:textSize="48sp" />
1919

2020
<!-- buttons layout in new liner layout-->
21+
<!-- Row 1-->
2122
<LinearLayout
2223
android:layout_width="match_parent"
2324
android:layout_height="0dp"
@@ -34,6 +35,7 @@
3435
android:text="@string/_7"
3536
android:textSize="20sp"
3637
tools:ignore="ButtonStyle,NestedWeights" />
38+
3739
<Button
3840
android:id="@+id/btnEight"
3941
android:layout_width="0dp"
@@ -67,5 +69,161 @@
6769

6870
</LinearLayout>
6971

72+
<!-- Row 2-->
73+
74+
<LinearLayout
75+
android:layout_width="match_parent"
76+
android:layout_height="0dp"
77+
android:layout_marginTop="2dp"
78+
android:layout_weight="1"
79+
android:orientation="horizontal">
80+
81+
<Button
82+
android:id="@+id/btnFour"
83+
android:layout_width="0dp"
84+
android:layout_height="match_parent"
85+
android:layout_weight="1"
86+
android:onClick="onDigit"
87+
android:text="@string/_4"
88+
android:textSize="20sp"
89+
tools:ignore="ButtonStyle,NestedWeights" />
90+
91+
<Button
92+
android:id="@+id/btnFive"
93+
android:layout_width="0dp"
94+
android:layout_height="match_parent"
95+
android:layout_weight="1"
96+
android:onClick="onDigit"
97+
android:text="@string/_5"
98+
android:textSize="20sp"
99+
tools:ignore="ButtonStyle,NestedWeights" />
100+
101+
<Button
102+
android:id="@+id/btnSix"
103+
android:layout_width="0dp"
104+
android:layout_height="match_parent"
105+
android:layout_weight="1"
106+
android:onClick="onDigit"
107+
android:text="@string/_6"
108+
android:textSize="20sp"
109+
tools:ignore="ButtonStyle,NestedWeights" />
110+
111+
<Button
112+
android:id="@+id/btnMulti"
113+
android:layout_width="0dp"
114+
android:layout_height="match_parent"
115+
android:layout_weight="1"
116+
android:onClick="onDigit"
117+
android:text="@string/multi"
118+
android:textSize="20sp"
119+
tools:ignore="ButtonStyle,NestedWeights" />
120+
121+
122+
</LinearLayout>
123+
124+
<!-- Row 3-->
125+
126+
<LinearLayout
127+
android:layout_width="match_parent"
128+
android:layout_height="0dp"
129+
android:layout_marginTop="2dp"
130+
android:layout_weight="1"
131+
android:orientation="horizontal">
132+
133+
<Button
134+
android:id="@+id/btnOne"
135+
android:layout_width="0dp"
136+
android:layout_height="match_parent"
137+
android:layout_weight="1"
138+
android:onClick="onDigit"
139+
android:text="@string/_1"
140+
android:textSize="20sp"
141+
tools:ignore="ButtonStyle,NestedWeights" />
142+
143+
<Button
144+
android:id="@+id/btnTwo"
145+
android:layout_width="0dp"
146+
android:layout_height="match_parent"
147+
android:layout_weight="1"
148+
android:onClick="onDigit"
149+
android:text="@string/_2"
150+
android:textSize="20sp"
151+
tools:ignore="ButtonStyle,NestedWeights" />
152+
153+
<Button
154+
android:id="@+id/btnThree"
155+
android:layout_width="0dp"
156+
android:layout_height="match_parent"
157+
android:layout_weight="1"
158+
android:onClick="onDigit"
159+
android:text="@string/_3"
160+
android:textSize="20sp"
161+
tools:ignore="ButtonStyle,NestedWeights" />
162+
163+
<Button
164+
android:id="@+id/btnSub"
165+
android:layout_width="0dp"
166+
android:layout_height="match_parent"
167+
android:layout_weight="1"
168+
android:onClick="onDigit"
169+
android:text="@string/sub"
170+
android:textSize="20sp"
171+
tools:ignore="ButtonStyle,NestedWeights" />
172+
173+
174+
</LinearLayout>
175+
176+
<!-- Row 4-->
177+
178+
<LinearLayout
179+
android:layout_width="match_parent"
180+
android:layout_height="0dp"
181+
android:layout_marginTop="2dp"
182+
android:layout_weight="1"
183+
android:orientation="horizontal">
184+
185+
<Button
186+
android:id="@+id/btnDot"
187+
android:layout_width="0dp"
188+
android:layout_height="match_parent"
189+
android:layout_weight="1"
190+
android:onClick="onDigit"
191+
android:text="@string/dot"
192+
android:textSize="20sp"
193+
tools:ignore="ButtonStyle,NestedWeights" />
194+
195+
<Button
196+
android:id="@+id/btnZero"
197+
android:layout_width="0dp"
198+
android:layout_height="match_parent"
199+
android:layout_weight="1"
200+
android:onClick="onDigit"
201+
android:text="@string/_0"
202+
android:textSize="20sp"
203+
tools:ignore="ButtonStyle,NestedWeights" />
204+
205+
<Button
206+
android:id="@+id/btnClear"
207+
android:layout_width="0dp"
208+
android:layout_height="match_parent"
209+
android:layout_weight="1"
210+
android:onClick="onDigit"
211+
android:text="@string/clear"
212+
android:textSize="20sp"
213+
tools:ignore="ButtonStyle,NestedWeights" />
214+
215+
<Button
216+
android:id="@+id/btnPlus"
217+
android:layout_width="0dp"
218+
android:layout_height="match_parent"
219+
android:layout_weight="1"
220+
android:onClick="onDigit"
221+
android:text="@string/plus"
222+
android:textSize="20sp"
223+
tools:ignore="ButtonStyle,NestedWeights" />
224+
225+
226+
</LinearLayout>
227+
70228

71229
</LinearLayout>

Calculator/app/src/main/res/values/strings.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,16 @@
44
<string name="_8">8</string>
55
<string name="_9">9</string>
66
<string name="divide">/</string>
7+
<string name="_4">4</string>
8+
<string name="_5">5</string>
9+
<string name="_6">6</string>
10+
<string name="multi">X</string>
11+
<string name="sub">-</string>
12+
<string name="_3">3</string>
13+
<string name="_2">2</string>
14+
<string name="_1">1</string>
15+
<string name="plus">+</string>
16+
<string name="clear">CLR</string>
17+
<string name="_0">0</string>
18+
<string name="dot">.</string>
719
</resources>

0 commit comments

Comments
 (0)