Android studio制作一个高仿计算器小demo

一、成品效果图

二、界面设计布局源代码:文件名activity_main.xml

<?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"
    tools:context="com.itlaowang.jisuanqi.MainActivity" >

    <EditText
        android:id="@+id/EV_Result"
        android:layout_width="match_parent"
        android:layout_height="209dp"
        android:ems="10"
        android:gravity="right|bottom"
        android:inputType="textPersonName"
        android:paddingRight="30dp"
        android:paddingBottom="30dp"
        android:text="0"
        android:textSize="60sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/Btn_C"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="C"
            android:textColor="#FF5722"
            android:textSize="40sp" />

        <Button
            android:id="@+id/Btn_Back"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="D"
            android:textSize="40sp" />

        <Button
            android:id="@+id/Btn_Division"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="/"
            android:textSize="40sp" />

        <Button
            android:id="@+id/Btn_Multiplication"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="*"
            android:textSize="40sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/Btn_Num7"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="7"
            android:textSize="40sp" />

        <Button
            android:id="@+id/Btn_Num8"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="8"
            android:textSize="40sp" />

        <Button
            android:id="@+id/Btn_Num9"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:background="@drawable/border2"
            android:text="9"
            android:textSize="40sp" />