Android Calculator App UI design example tutorial free UI Android Studio

How to get best design (User Interface) for simple calculator with Fully responsive all device size support.

This the first tutorial on our website regarding to create a complete UI(User Interface) . This UI is for Calculator android application with basic operation support like addition, multiplication, subtraction, divide, percent, minus values, brackets. This UI is designed using Table widget. So here is the complete step by step tutorial for Android Calculator App UI design example tutorial free UI Android Studio.

Note  : This design is completely open source and free for every one. You can download the whole project from below link and can use it any where.

android-project-download-code-button

Android Calculator App UI design example tutorial free UI Android Studio.

Code for MainActivity.java file.

package com.android_examples.calculator_android_examplescom;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    TextView textView;

    Button clear, bracket, percentage, divide, add, subtract, multiply, equal, minusValue;

    Button one, two, three, four, five, six, seven, eight, nine, point, zero ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //code for hide title bar.
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_main);

        textView = (TextView)findViewById(R.id.textView1);

        clear = (Button)findViewById(R.id.buttonClearText);
        bracket = (Button)findViewById(R.id.buttonBracket);
        percentage = (Button)findViewById(R.id.buttonPercentage);
        divide = (Button)findViewById(R.id.buttonDivide);
        add = (Button)findViewById(R.id.buttonAdd);
        subtract = (Button)findViewById(R.id.buttonSubtraction);
        multiply = (Button)findViewById(R.id.buttonMultiply);
        equal = (Button)findViewById(R.id.buttonEqual);
        minusValue = (Button)findViewById(R.id.buttonMinusValue);

        one = (Button)findViewById(R.id.button1);
        two = (Button)findViewById(R.id.button2);
        three = (Button)findViewById(R.id.button3);
        four = (Button)findViewById(R.id.button4);
        five = (Button)findViewById(R.id.button5);
        six = (Button)findViewById(R.id.button6);
        seven = (Button)findViewById(R.id.button7);
        eight = (Button)findViewById(R.id.button8);
        nine = (Button)findViewById(R.id.button9);
        point = (Button)findViewById(R.id.buttonPoint);
        zero = (Button)findViewById(R.id.buttonZero);

        clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(null);
            }
        });


        bracket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

               String S = textView.getText().toString();

            }
        });

        percentage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "%");

            }
        });


        divide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "/");

            }
        });


        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "+");
            }
        });


        subtract.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "-");

            }
        });


        multiply.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "*");

            }
        });


        equal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {



            }
        });


        minusValue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        one.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "1");

            }
        });

        two.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "2");

            }
        });

        three.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "3");

            }
        });

        four.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "4");

            }
        });

        five.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "5");

            }
        });


        six.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "6");

            }
        });


        seven.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "7");

            }
        });

        eight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "8");

            }
        });

        nine.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "9");

            }
        });

        point.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + ".");

            }
        });

        zero.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                textView.setText(textView.getText() + "0");

            }
        });
    }

}

Code for activity_main.xml layout file.

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:shrinkColumns="*"
    android:stretchColumns="*"
    android:background="#CFD8DC"
    android:weightSum="120">

    <!--     Row 1 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="20"
        android:background="#FFFFFF">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="number"
            android:id="@+id/textView1"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@null"
            android:gravity="right"
            android:layout_span="4"
            android:textSize="40dp"
            android:typeface="monospace"
            android:textColor="#000000"
            />

    </TableRow>

    <!--     Row 2 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:background="#ECEFF1"
        android:layout_weight="20">

        <Button
            android:id="@+id/buttonClearText"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="C"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            />

        <Button
            android:id="@+id/buttonBracket"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="( )"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"/>

        <Button
            android:id="@+id/buttonPercentage"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="%"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"/>


        <Button
            android:id="@+id/buttonDivide"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="/"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            />

    </TableRow>


    <!--     Row 3 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="20"
        >

        <Button
            android:id="@+id/button7"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="7"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"
            />

        <Button
            android:id="@+id/button8"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="8"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/button9"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="9"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            android:layout_marginRight="1dp"/>


        <Button
            android:id="@+id/buttonAdd"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="+"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"/>

    </TableRow>


    <!--     Row 4 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="20">

        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="4"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="5"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="6"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            android:layout_marginRight="1dp"/>


        <Button
            android:id="@+id/buttonSubtraction"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="-"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            />


    </TableRow>


    <!--     Row 5 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="20">


        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="1"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="2"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="3"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            android:layout_marginRight="1dp"/>

        <Button
            android:id="@+id/buttonMultiply"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="x"
            android:textSize="35dp"
            android:background="#607D8B"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"/>


    </TableRow>


    <!--     Row 6 Starts From Here -->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="20">


        <Button
            android:id="@+id/buttonPoint"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="."
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/buttonZero"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="0"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginRight="1dp"
            android:layout_marginTop="1dp"/>

        <Button
            android:id="@+id/buttonMinusValue"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="+-"
            android:textSize="35dp"
            android:background="#ECEFF1"
            android:textColor="#000000"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            android:layout_marginRight="1dp"/>

        <Button
            android:id="@+id/buttonEqual"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="="
            android:textSize="35dp"
            android:background="#FF9800"
            android:textColor="#FFFFFF"
            android:layout_span="1"
            android:typeface="monospace"
            android:layout_marginTop="1dp"
            />


    </TableRow>



</TableLayout>

Code for styles.xml file.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

Screenshot:

Android Calculator App UI design example tutorial free UI Android Studio

Click here to download Android Calculator App UI design example tutorial free UI Android Studio project with source code free.