Wednesday 26 July 2017

Design of Scientific Calculator in Android

Layout to design Scientific calculator in Android.





Step-1:- While creating my project I am using empty activity.You can use any activity according to your requirement.                                   


        All written content of my project I use string.xml file.I also give string.xml file for scientific               calculator.

        string.xml
     
<resources>
    <string name="app_name">MyModernCalculator</string>
    <string name="C">C</string>
    <string name="B">B</string>
    <string name="mod">%</string>
    <string name="divide">÷ </string>
    <string name="MD7">7</string>
    <string name="MD8">8</string>
    <string name="MD9">9</string>
    <string name="MCX">×</string>
    <string name="MC4">4</string>
    <string name="MC5">5</string>
    <string name="MC6">6</string>
    <string name="MCsub">−</string>
    <string name="MC1">1</string>
    <string name="MC2">2</string>
    <string name="MC3">3</string>
    <string name="MCplus">+</string>
    <string name="MC.">.</string>
    <string name="MC0">0</string>
    <string name="MCequal">=</string>
    <string name="slash">+/−</string>
    <string name="powerXy">"X<sup><small>y</small></sup>"</string>
    <string name="powerex">"e<sup><small>x</small></sup>"</string>
    <string name="powerYx">"Y<sup><small>x</small></sup>"</string>
    <string name="power10x">"10<sup><small>x</small></sup>"</string>
    <string name="powerLogy">"log<sup><small>y</small></sup>"</string>
    <string name="powerX2">"X<sup><small>2</small></sup>"</string>
    <string name="power2nd">"2<sup><small>nd</small></sup>"</string>
    <string name="power2x">"2<sup><small>x</small></sup>"</string>
    <string name="ln">ln</string>
    <string name="pi">π</string>
    <string name="lbracket">(</string>
    <string name="Rbracket">)</string>
    <string name="MC">MC</string>
    <string name="Mplus">M+</string>
    <string name="Mminus">M-</string>
    <string name="MR">MR</string>
    <string name="divide1x">1/x</string>
    <string name="xnotequal">x!</string>
    <string name="log">log</string>
    <string name="yunderootx">"<sup><small>y</small></sup>√X"</string>
</resources>



Step-2:- In your activity_main.xml paste the code mention below.This activity_main.xml work for portrait mode for mobile.
                                                                                                                                                                
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="3"
    tools:context="com.example.hp.mymoderncalculator.MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#444444"
        android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:layout_weight="2"
        android:weightSum="4">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="5"
        >
        <Button
            android:id="@+id/BC"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:textSize="30sp"
            android:textColor="#ffffff"
            android:background="@drawable/button1"
            android:text="@string/C"
            android:layout_margin="0.2dp"/>
        <Button
            android:id="@+id/B7"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"

            android:textSize="30sp"
            android:textColor="#000000"
            android:background="@drawable/button"
            android:text="@string/MD7"
            android:layout_margin="0.2dp"/>
        <Button
        android:id="@+id/B4"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        android:textSize="30sp"
        android:textColor="#000000"
        android:background="@drawable/button"
        android:text="@string/MC4"
            android:layout_margin="0.2dp"/>
        <Button
            android:id="@+id/B1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"

            android:textSize="30sp"
            android:textColor="#000000"
            android:background="@drawable/button"
            android:text="@string/MC1"
            android:layout_margin="0.2dp"/>
        <Button
            android:id="@+id/B."
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:textStyle="bold"
            android:textSize="30sp"
            android:textColor="#000000"
            android:background="@drawable/button"
            android:text="@string/MC."
            android:layout_margin="0.2dp"/>

    </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="5">
            <ImageButton
                android:id="@+id/BB"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:src="@drawable/ic_backspace"
                android:textColor="#ffffff"
                android:background="@drawable/button1"
                android:text="@string/B"
                android:layout_margin="0.2dp"
                />

            <Button
                android:id="@+id/B8"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MD8"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B5"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC5"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC2"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B0"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC0"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Bmod"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button1"
                android:text="@string/mod"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B9"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MD9"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B6"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC6"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B3"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC3"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bequal"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MCequal"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Bdivide"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/divide"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bmulti"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCX"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bsubtract"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCsub"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bplus"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="2"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCplus"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
    </LinearLayout>

</LinearLayout>

Step-3:- To give the button pressing effect I am creating 3 xml file.To create xml file go to app→res-               →drawable.Right click on drawable go to new then drawable resource file onclick open                          popwindow open.Type name just as i am using button.xml.

    button.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#aaaaaa" />
            <stroke
                android:width="0dp"
                android:color="#222222" />

        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#ffffff"
                android:endColor="#ffffff"
                android:angle="270" />
            <stroke
                android:width="0dp"
                android:color="#000000" />


        </shape>
    </item>
</selector>

button1.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#00ccff" />
            <stroke
                android:width="0dp"
                android:color="#222222" />

        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#66c2ff"
                android:endColor="#66c2ff"
                android:angle="270" />
            <stroke
                android:width="0dp"
                android:color="#000000" />


        </shape>
    </item>
</selector>


button3.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#c2c3c6" />
            <stroke
                android:width="0dp"
                android:color="#222222" />

        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#4fe1dedf"
                android:endColor="#4fe1dedf"
                android:angle="270" />
            <stroke
                android:width="0dp"
                android:color="#000000" />


        </shape>
    </item>
</selector>


I am using three button of different color thats why to give click effect or change color onclick i am using 3 xml file like button.xml,button1.xml and button3.xml.You can give these xml name of your own choice.



Step-4:- To add thid delete symbol I am using vector asset an inbuilt feature of android studio.
               To add this in your button go to drawable →(right click ) new→select vector asset double                  click on android icon button search desired icon from list and press Ok.Then press next and               then finish.A new component add in drawable.Now you can add this icon to desired place                   using syntax android:src="@drawable/" .In inverted comas use name of component newly               added from adding icon.In my project i am using this.You can watch my code.

Step-5:- Its time to change orientation from portrait to landscape.For this we need to create new                         activity_main.xml.In res go to layout (right click) layout drawable click on that.Apop box                   open in this box type infront of file name type activity_main.xml.Name should same as                       default xml file of project.Infront of directory name after layout use(-land) and combination                 of both look like (layout-land) to create landscape orientation.Inside this file type or paste                    the below code.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="3">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#444444"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:layout_weight="2"
        android:weightSum="10">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="5"
            android:layout_weight="1"
            >
            <Button
                android:id="@+id/Lbracket"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="20sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/lbracket"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/second"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textSize="20sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/power2nd"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/onebyx"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/divide1x"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Rand"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="Rand"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Deg"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textColor="#00ffff"
                android:background="@drawable/button3"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:text="Deg"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="5"
            android:layout_weight="1"
            >
            <Button
                android:id="@+id/Rbracket"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="20sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/Rbracket"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/multiplyx"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textAllCaps="false"
                android:textSize="20sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/power2x"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/notequal"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/xnotequal"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/tan"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="tan"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/tanh"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textAllCaps="false"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="tanh"
                android:fontFamily="Times new Roman"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="5"
            android:layout_weight="1"
            >
            <Button
                android:id="@+id/Mc"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/MC"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Xy"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/powerXy"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/yunderroot"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/yunderootx"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/sin"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="sin"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/sinh"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="sinh"
                android:layout_margin="0.2dp"/>

        </LinearLayout>


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Mplus"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/Mplus"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/xsquare"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/powerX2"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/underrooty"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="√X"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/cos"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:fontFamily="Times new Roman"
                android:textAllCaps="false"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="cos"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/cosh"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="cosh"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Mminus"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/Mminus"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/e"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="20sp"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="e"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/pi"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textSize="20sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/pi"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Yx"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="20sp"
                android:textColor="#000000"
                android:textAllCaps="false"
                android:background="@drawable/button3"
                android:fontFamily="Times new Roman"
                android:text="@string/powerYx"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/logy"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textAllCaps="false"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/powerLogy"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/MR"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="15sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/MR"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/ex"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textSize="20sp"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/powerex"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/x10"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="20sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/ln"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B3"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button3"
                android:text="@string/power10x"
                android:textAllCaps="false"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bequal"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="15sp"
                android:textAllCaps="false"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button3"
                android:text="@string/log"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Bmod"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:fontFamily="Times new Roman"
                android:textColor="#ffffff"
                android:background="@drawable/button1"
                android:text="@string/C"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B9"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textAllCaps="false"
                android:textSize="30sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button"
                android:text="@string/MD7"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B6"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC4"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B3"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:fontFamily="Times new Roman"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC1"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bequal"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button"
                android:text="@string/MC."
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:weightSum="5">
            <ImageButton
                android:id="@+id/BB"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:src="@drawable/ic_backspace"
                android:textColor="#ffffff"
                android:background="@drawable/button1"
                android:text="@string/B"
                android:layout_margin="0.2dp"
                />

            <Button
                android:id="@+id/B8"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MD8"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B5"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC5"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC2"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B0"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:fontFamily="Times new Roman"
                android:background="@drawable/button"
                android:text="@string/MC0"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Bmod"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button1"
                android:text="@string/mod"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B9"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MD9"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B6"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:fontFamily="Times new Roman"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC6"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/B3"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MC3"
                android:fontFamily="Times new Roman"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bequal"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#000000"
                android:background="@drawable/button"
                android:text="@string/MCequal"
                android:fontFamily="Times new Roman"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <Button
                android:id="@+id/Bdivide"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/slash"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bmulti"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/divide"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bsubtract"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"

                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCX"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bplus"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCsub"
                android:layout_margin="0.2dp"/>
            <Button
                android:id="@+id/Bplus"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:textSize="30sp"
                android:textColor="#ffffff"
                android:background="@drawable/button2"
                android:text="@string/MCplus"
                android:layout_margin="0.2dp"/>

        </LinearLayout>
    </LinearLayout>


</LinearLayout>


design of scientific calculator in Android finish.Now you can write code according to your  requirement to make this calculator functioning.

8 comments:

  1. plz give code for MainActivity.java

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. bro how to create main activity ?

    ReplyDelete
  4. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article. math

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. he tasks of performing algebraic equations and adding perfection to the given set of problem sums are somewhat challenging. matrix calculator here comes to your use and is amazing.

    ReplyDelete

Change Fragment on button click in Android

In example mention below on click of a button, we attach the desired fragment in our frame layout which was present in activity_main.xml. ...