前言:
利用表格布局(TableLayout)实现界面样式,通过Spinner控件选择运算符,实现两个数之间的加减乘除。
一、效果图:
二、开发环境
- 开发工具:Android Studio 3.1.4
- 虚拟器:Genymotion
添加相应的数据放到values文件夹下的strings.xml中,如下图所示:
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<TableLayout 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:gravity="center"
tools:context=".MainActivity">
<TableRow android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:textSize="25sp"
android:textColor="#000"
android:text="简易计算器" />
</TableRow>
<TableRow>
<TextView