我使用的是线性布局,也可以使用表格布局,但是暂时还没有学到
首先来看一下布局格式代码,直接将代码写在activity_main中:
<?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">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<EditText
android:id="@+id/re"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@null" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<Button
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1"
android:layout_weight="1"/>
<Button
android:id="@+id/b2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2"
android:layout_weight="1"/>
<Button
android:id="@+id/b3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3"
android:layout_weight="1"/>
<Button
android:id="@+id/b4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="/"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/b5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4"
android:layout_weight="1"/>
<Button
android:id="@+id/b6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="5"
android:layout_weight="1"/>
<Button
android:id="@+id/b7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
androi