1. activity.xml文件中代码:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context=".jisuanqiActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape" android:text="C" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="+/-" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="%" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape_ring" android:text="/" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape" android:text="1" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="2" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="3" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape_ring" android:text="×" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="4" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="5" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="6" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape_ring" android:text="-" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="7" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="8" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="9" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape_ring" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="2" android:textSize="30sp" android:gravity="center" android:text="0" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/shape" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:text="·" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="30sp" android:gravity="center" android:background="@drawable/shape_ring" android:text="=" /> </LinearLayout> </LinearLayout>
2.drawable下面shape.xml代码:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="1dp"/> <solid android:color="#ffffff"/> <stroke android:width="2dp" android:color="#333333"/> <!-- <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp"/>--> </shape>
3.drawable下面shape_ring.xml代码:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="1dp"/> <solid android:color="#e47f26"/> <stroke android:width="2dp" android:color="#333333"/> <!-- <padding android:bottom="5dp" android:left="10dp" android:right="10dp" android:top="5dp"-->/> </shape>