In this tutorial you will learn how to make a simple android calculator app. More precisely, in this first part we will be dealing with the UI – writing XML, using LinearLayout, GridLayout, support libraries, custom styles and more Android goodness!
This post contains all the code that’s been written in this YouTube video.
You can also check out the GitHub repository: https://github.com/ResoCoder/Simple-Calculator—Xamarin-Android
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="@+id/calculator_text_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:textSize="50sp"
android:text="123" />
</HorizontalScrollView>
<android.support.v7.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
app:orientation="horizontal"
app:rowCount="5"
app:columnCount="4">
<Button
style="@style/button_calculator"
app:layout_columnSpan="4"
android:text="DEL" />
<Button
style="@style/button_calculator"
android:text="7" />
<Button
style="@style/button_calculator"
android:text="8" />
<Button
style="@style/button_calculator"
android:text="9" />
<Button
style="@style/button_calculator"
android:text="÷" />
<Button
style="@style/button_calculator"
android:text="4" />
<Button
style="@style/button_calculator"
android:text="5" />
<Button
style="@style/button_calculator"
android:text="6" />
<Button
style="@style/button_calculator"
android:text="×" />
<Button
style="@style/button_calculator"
android:text="1" />
<Button
style="@style/button_calculator"
android:text="2" />
<Button
style="@style/button_calculator"
android:text="3" />
<Button
style="@style/button_calculator"
android:text="-" />
<Button
style="@style/button_calculator"
android:text="." />
<Button
style="@style/button_calculator"
android:text="0" />
<Button
style="@style/button_calculator"
android:text="=" />
<Button
style="@style/button_calculator"
android:text="+" />
</android.support.v7.widget.GridLayout>
</LinearLayout>
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="button_calculator">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">0dp</item>
<item name="layout_rowWeight">1</item>
<item name="layout_columnWeight">1</item>
<item name="android:textSize">25dp</item>
<item name="android:onClick">ButtonClick</item>
</style>
</resources>

I get the following error:
Severity Code Description Project File Line Suppression State
Error No resource found that matches the given name (at ‘theme’ with value ‘@style/AppTheme’). Calc3 P:\C#\Android\Calc3\Calc3\obj\Debug\MonoAndroid81\android\manifest\AndroidManifest.xml 7
And here’s the Manifest file:
Also when I tried to send the comment I got this:
Notice: Trying to get property of non-object in /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 717
Notice: Trying to get property of non-object in /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 727
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-content/plugins/jetpack/modules/subscriptions.php on line 764
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-content/plugins/jetpack/modules/subscriptions.php on line 770
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-includes/comment.php on line 541
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-includes/comment.php on line 542
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-includes/comment.php on line 543
Warning: Cannot modify header information – headers already sent by (output started at /home/resocode/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php:717) in /home/resocode/public_html/wp-includes/pluggable.php on line 1219
And here’s the Manifest file:
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Your article helped me a lot, is there any more related content? Thanks!
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.