目录
一、提出要求
二、创建按钮边框配置文件
1.示例代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#DDDDDD" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
<stroke
android:width="0.5dp"
android:color="#dddddd"/>
</shape>
2.效果图
三、字符资源文件
<resources>
<string name="app_name">Calcuator</string>
<string name="number">请输入数字</string>
<string name="mc">MC</string>
<string name="mr">MR</string>
<string name="ms">MS</string>
<string name="mm">M+</string>
<string name="mmm">M-</string>
<string name="tuiwei">←</string>
<string name="ce">CE</string>
<string name="c">C</string>
<string name="add_sub">+/-</string>
<string name="gen">√</string>
<string name="seven">7</string>
<string name="eight">8</string>
<string name="nine">9</string>
<string name="chu">/</string>
<string name="quyu">%</string>
<string name="four">4</string>
<string name="five">5</string>
<string name="six">6</string>
<string name="cheng">*</string>
<string name="fen">1/x</string>
<string name="one">1</string>
<string name="two">2</string>
<string name="three">3</string>
<string name="sub">-</string>
<string name="deng">=</string>
<string name="zero">0</string>
<string name="point">.</string>
<string name="add">+</string>
</resources>
四、主布局资源文件
1.分析权重
2.示例代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="@mipmap/bg_xx"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:gravity="center"
android:layout_weight="1.5">
<EditText
android:id="@+id/edt_number"
android:layout_width="300dp"
android:layout_height="100dp"
android:background="#aaaaaa"
android:gravity="center_vertical|right"
android:hint="@string/number"
android:singleLine="true"></EditText>
</LinearLayout>
<LinearLayout
android:layout_width="350dp"
android:layout_height="155dp"
android:orientation="vertical"
android:layout_weight="2.5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">