Android简单计算器
设计Android简单计算器
此次通过设计一个简单的计算器来巩固课堂上所学到的知识,熟悉Android的编程设计。
界面设计
计算器功能实现简单的加减乘除,混合运算。
- 效果图
- 代码
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="6"
android:columnCount="4"
tools:context=".MainActivity">
<TextView
android:id="@+id/show_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="4"
android:layout_marginLeft="4px"
android:gravity="center_vertical|right"
android:text="0"
android:textSize="50dp"/>
<Button
android:id="@+id/buttonClear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_columnSpan="4"
android:text="清除"
android:textSize="26sp"
android:background="#FF0000"
/>
<Button
android:id="@+id/buttonPop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_columnSpan="4"
android:text="删除"
android:textSize="26sp"
/>
<Button