代码:
activity_3.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".Activity3">
<RelativeLayout
android:id="@+id/r1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#1000"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:layout_margin="6dp"
android:textSize="24sp"
android:text="">
</TextView>
<TextView
android:id="@+id/textv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="0"
android:padding="20dp"
android:textSize="30sp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="22dp"
android:onClick="onClick"
android:text="%"
android:backgroundTint="#A67D3D"
android:textColor="#171616"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="22dp"
android:onClick="onClicka"
android:text="CE"
android:backgroundTint="#A67D3D"
android:textColor="#171616"
tools:ignore="OnClick" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="22dp"
android:onClick="onClick"
android:textAllCaps="false"
android:text="Back"
android:backgroundTint="#A67D3D"
android:textColor="#171616"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#E91E63"
android:backgroundTint="#8E2323"
android:onClick="onClick"
android:text="÷"
android:textSize="24dp"
app:backgroundTint="#2196F3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="24dp"
android:onClick="onClick"
android:text="1"
android:backgroundTint="#0000FF"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="24dp"
android:onClick="onClick"
android:text="2"
android:backgroundTint="#0000FF"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="24dp"