Skip to content

Commit 0886fc0

Browse files
committed
Tablet views for simple calculator
1 parent 2e65271 commit 0886fc0

File tree

3 files changed

+349
-0
lines changed

3 files changed

+349
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".activities.SimpleCalculatorActivity"
8+
android:orientation="vertical">
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="0dp"
13+
android:layout_weight="0.55"
14+
android:orientation="vertical">
15+
16+
<TextView
17+
android:id="@+id/previous_value_text_view"
18+
android:text=""
19+
android:layout_width="match_parent"
20+
android:layout_height="0dp"
21+
android:layout_weight="0.45"
22+
android:textSize="30sp"
23+
android:gravity="bottom|right"
24+
android:textColor="@color/gray"
25+
android:paddingRight="10dp"
26+
android:paddingLeft="10dp"
27+
android:autoSizeTextType="uniform"/>
28+
29+
<TextView
30+
android:text=""
31+
android:layout_width="match_parent"
32+
android:layout_height="0dp"
33+
android:layout_weight="0.3"
34+
android:gravity="top|right"
35+
android:id="@+id/operation_text_view"
36+
android:paddingRight="10dp"
37+
android:textSize="48sp"/>
38+
39+
</LinearLayout>
40+
41+
<TextView
42+
android:text="0"
43+
android:layout_width="match_parent"
44+
android:layout_height="0dp"
45+
android:layout_weight="0.35"
46+
android:id="@+id/value_text_view"
47+
android:gravity="bottom|end"
48+
android:textSize="72sp"
49+
android:paddingRight="10dp"
50+
android:paddingLeft="10dp"
51+
android:autoSizeTextType="uniform"/>
52+
53+
<GridLayout
54+
android:layout_width="match_parent"
55+
android:layout_height="0dp"
56+
android:layout_weight="2"
57+
android:rowCount="5"
58+
android:columnCount="4">
59+
60+
<Button
61+
android:id="@+id/btn_all_clear"
62+
android:text="AC"
63+
android:backgroundTint="@color/orange"
64+
android:layout_columnSpan="2"
65+
android:textStyle="bold"
66+
style="@style/ButtonStyleSimpleTablet"/>
67+
68+
<Button
69+
android:id="@+id/btn_clear_or_clear_all"
70+
android:text="C/CE"
71+
android:paddingLeft="0dp"
72+
android:paddingRight="0dp"
73+
android:textSize="60sp"
74+
android:textStyle="bold"
75+
style="@style/ButtonStyleSimpleTablet"/>
76+
77+
<Button
78+
android:id="@+id/btn_divide"
79+
android:text="÷"
80+
style="@style/ButtonStyleSimpleTablet"/>
81+
82+
<Button
83+
android:id="@+id/btn7"
84+
android:text="7"
85+
style="@style/ButtonStyleSimpleTablet"/>
86+
87+
<Button
88+
android:id="@+id/btn8"
89+
android:text="8"
90+
style="@style/ButtonStyleSimpleTablet"/>
91+
92+
<Button
93+
android:id="@+id/btn9"
94+
android:text="9"
95+
style="@style/ButtonStyleSimpleTablet"/>
96+
97+
<Button
98+
android:id="@+id/btn_multiply"
99+
android:text=""
100+
style="@style/ButtonStyleSimpleTablet"/>
101+
102+
<Button
103+
android:id="@+id/btn4"
104+
android:text="4"
105+
style="@style/ButtonStyleSimpleTablet"/>
106+
107+
<Button
108+
android:id="@+id/btn5"
109+
android:text="5"
110+
style="@style/ButtonStyleSimpleTablet"/>
111+
112+
<Button
113+
android:id="@+id/btn6"
114+
android:text="6"
115+
style="@style/ButtonStyleSimpleTablet"/>
116+
117+
<Button
118+
android:id="@+id/btn_minus"
119+
android:text=""
120+
style="@style/ButtonStyleSimpleTablet"/>
121+
122+
<Button
123+
android:id="@+id/btn1"
124+
android:text="1"
125+
style="@style/ButtonStyleSimpleTablet"/>
126+
127+
<Button
128+
android:id="@+id/btn2"
129+
android:text="2"
130+
style="@style/ButtonStyleSimpleTablet"/>
131+
132+
<Button
133+
android:id="@+id/btn3"
134+
android:text="3"
135+
style="@style/ButtonStyleSimpleTablet"/>
136+
137+
<Button
138+
android:id="@+id/btn_plus"
139+
android:text="+"
140+
style="@style/ButtonStyleSimpleTablet"/>
141+
142+
<Button
143+
android:id="@+id/btn_plus_minus"
144+
android:text="+/-"
145+
android:paddingLeft="0dp"
146+
android:paddingRight="0dp"
147+
android:textSize="60sp"
148+
style="@style/ButtonStyleSimpleTablet"/>
149+
150+
<Button
151+
android:id="@+id/btn0"
152+
android:text="0"
153+
style="@style/ButtonStyleSimpleTablet"/>
154+
155+
<Button
156+
android:id="@+id/btn_comma"
157+
android:text=","
158+
style="@style/ButtonStyleSimpleTablet"/>
159+
160+
<Button
161+
android:id="@+id/btn_equals"
162+
android:text="="
163+
style="@style/ButtonStyleSimpleTablet"/>
164+
165+
</GridLayout>
166+
167+
</LinearLayout>
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".activities.SimpleCalculatorActivity"
8+
android:orientation="vertical">
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="0dp"
13+
android:layout_weight="0.5"
14+
android:orientation="vertical">
15+
16+
<TextView
17+
android:id="@+id/previous_value_text_view"
18+
android:text=""
19+
android:layout_width="match_parent"
20+
android:layout_height="0dp"
21+
android:layout_weight="0.65"
22+
android:textSize="30sp"
23+
android:gravity="bottom|right"
24+
android:textColor="@color/gray"
25+
android:paddingRight="10dp"
26+
android:paddingLeft="10dp"
27+
android:autoSizeTextType="uniform"/>
28+
29+
<TextView
30+
android:text=""
31+
android:layout_width="match_parent"
32+
android:layout_height="0dp"
33+
android:layout_weight="0.35"
34+
android:gravity="top|right"
35+
android:id="@+id/operation_text_view"
36+
android:paddingRight="10dp"
37+
android:textSize="56sp"/>
38+
39+
</LinearLayout>
40+
41+
<TextView
42+
android:text="0"
43+
android:layout_width="match_parent"
44+
android:layout_height="0dp"
45+
android:layout_weight="0.35"
46+
android:id="@+id/value_text_view"
47+
android:gravity="bottom|end"
48+
android:textSize="72sp"
49+
android:paddingRight="10dp"
50+
android:paddingLeft="10dp"
51+
android:autoSizeTextType="uniform"/>
52+
53+
<GridLayout
54+
android:layout_width="match_parent"
55+
android:layout_height="0dp"
56+
android:layout_weight="2"
57+
android:rowCount="5"
58+
android:columnCount="4">
59+
60+
<Button
61+
android:id="@+id/btn_all_clear"
62+
android:text="AC"
63+
android:backgroundTint="@color/orange"
64+
android:layout_columnSpan="2"
65+
android:textStyle="bold"
66+
style="@style/ButtonStyleSimpleTablet"/>
67+
68+
<Button
69+
android:id="@+id/btn_clear_or_clear_all"
70+
android:text="C/CE"
71+
android:paddingLeft="0dp"
72+
android:paddingRight="0dp"
73+
android:textSize="60sp"
74+
android:textStyle="bold"
75+
style="@style/ButtonStyleSimpleTablet"/>
76+
77+
<Button
78+
android:id="@+id/btn_divide"
79+
android:text="÷"
80+
style="@style/ButtonStyleSimpleTablet"/>
81+
82+
<Button
83+
android:id="@+id/btn7"
84+
android:text="7"
85+
style="@style/ButtonStyleSimpleTablet"/>
86+
87+
<Button
88+
android:id="@+id/btn8"
89+
android:text="8"
90+
style="@style/ButtonStyleSimpleTablet"/>
91+
92+
<Button
93+
android:id="@+id/btn9"
94+
android:text="9"
95+
style="@style/ButtonStyleSimpleTablet"/>
96+
97+
<Button
98+
android:id="@+id/btn_multiply"
99+
android:text=""
100+
style="@style/ButtonStyleSimpleTablet"/>
101+
102+
<Button
103+
android:id="@+id/btn4"
104+
android:text="4"
105+
style="@style/ButtonStyleSimpleTablet"/>
106+
107+
<Button
108+
android:id="@+id/btn5"
109+
android:text="5"
110+
style="@style/ButtonStyleSimpleTablet"/>
111+
112+
<Button
113+
android:id="@+id/btn6"
114+
android:text="6"
115+
style="@style/ButtonStyleSimpleTablet"/>
116+
117+
<Button
118+
android:id="@+id/btn_minus"
119+
android:text=""
120+
style="@style/ButtonStyleSimpleTablet"/>
121+
122+
<Button
123+
android:id="@+id/btn1"
124+
android:text="1"
125+
style="@style/ButtonStyleSimpleTablet"/>
126+
127+
<Button
128+
android:id="@+id/btn2"
129+
android:text="2"
130+
style="@style/ButtonStyleSimpleTablet"/>
131+
132+
<Button
133+
android:id="@+id/btn3"
134+
android:text="3"
135+
style="@style/ButtonStyleSimpleTablet"/>
136+
137+
<Button
138+
android:id="@+id/btn_plus"
139+
android:text="+"
140+
style="@style/ButtonStyleSimpleTablet"/>
141+
142+
<Button
143+
android:id="@+id/btn_plus_minus"
144+
android:text="+/-"
145+
android:paddingLeft="0dp"
146+
android:paddingRight="0dp"
147+
android:textSize="60sp"
148+
style="@style/ButtonStyleSimpleTablet"/>
149+
150+
<Button
151+
android:id="@+id/btn0"
152+
android:text="0"
153+
style="@style/ButtonStyleSimpleTablet"/>
154+
155+
<Button
156+
android:id="@+id/btn_comma"
157+
android:text=","
158+
style="@style/ButtonStyleSimpleTablet"/>
159+
160+
<Button
161+
android:id="@+id/btn_equals"
162+
android:text="="
163+
style="@style/ButtonStyleSimpleTablet"/>
164+
165+
</GridLayout>
166+
167+
</LinearLayout>

app/src/main/res/values/styles.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
<item name="android:gravity">center</item>
1717
</style>
1818

19+
<style name="ButtonStyleSimpleTablet">
20+
<item name="android:textSize">72sp</item>
21+
<item name="android:layout_width">0dp</item>
22+
<item name="android:layout_height">0dp</item>
23+
<item name="android:layout_rowWeight">1</item>
24+
<item name="android:layout_columnWeight">1</item>
25+
<item name="android:layout_marginLeft">5dp</item>
26+
<item name="android:layout_marginRight">5dp</item>
27+
<item name="android:layout_marginTop">2dp</item>
28+
<item name="android:layout_marginBottom">2dp</item>
29+
<item name="android:paddingTop">0dp</item>
30+
<item name="android:paddingBottom">0dp</item>
31+
<item name="android:gravity">center</item>
32+
</style>
33+
1934
<style name="ButtonStyleLandscapeSimple">
2035
<item name="android:textSize">30sp</item>
2136
<item name="android:layout_width">0dp</item>

0 commit comments

Comments
 (0)