Constraintlayout布局
<?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"
android:background="@color/calc_bg1"
tools:context=".CalcConstraintActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_gravity="center_horizontal|top"
android:gravity="end|center_vertical"
android:padding="20dp"
android:text="@string/bt_0"
android:textColor="@color/black"
android:textSize="50sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/bt_mc"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
app:layout_constraintHorizontal_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mc"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_mr"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_mr"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mr"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/bt_mc"
app:layout_constraintEnd_toStartOf="@id/bt_mi"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_mi"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mi"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/bt_mr"
app:layout_constraintEnd_toStartOf="@id/bt_md"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_md"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
app:layout_constraintHorizontal_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_md"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/bt_mi"
app:layout_constraintEnd_toStartOf="@id/bt_ms"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_ms"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_ms"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/bt_md"
app:layout_constraintEnd_toStartOf="@id/bt_m"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_m"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_m"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/bt_ms"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView1" />
<Button
android:id="@+id/bt_p"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_p"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_g"
app:layout_constraintTop_toBottomOf="@id/bt_mc" />
<Button
android:id="@+id/bt_g"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
app:layout_constraintHorizontal_weight="1"
android:text="@string/radical"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_p"
app:layout_constraintEnd_toStartOf="@id/bt_x2"
app:layout_constraintTop_toBottomOf="@id/bt_mc" />
<Button
android:id="@+id/bt_x2"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x2"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_g"
app:layout_constraintEnd_toStartOf="@id/bt_1x"
app:layout_constraintTop_toBottomOf="@id/bt_mc" />
<Button
android:id="@+id/bt_1x"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_1x"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_x2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_mc" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_ce"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_ce"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_c"
app:layout_constraintTop_toBottomOf="@id/bt_p" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_c"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_c"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_ce"
app:layout_constraintEnd_toStartOf="@id/bt_x"
app:layout_constraintTop_toBottomOf="@id/bt_p" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_x"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_c"
app:layout_constraintEnd_toStartOf="@id/bt_div"
app:layout_constraintTop_toBottomOf="@id/bt_p" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_div"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_div"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_x"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_p" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_7"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_7"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_8"
app:layout_constraintTop_toBottomOf="@id/bt_ce" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_8"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_8"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_7"
app:layout_constraintEnd_toStartOf="@id/bt_9"
app:layout_constraintTop_toBottomOf="@id/bt_ce" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_9"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_9"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_8"
app:layout_constraintEnd_toStartOf="@id/bt_mut"
app:layout_constraintTop_toBottomOf="@id/bt_ce" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_mut"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_mut"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_ce" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_4"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_4"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_5"
app:layout_constraintTop_toBottomOf="@id/bt_7" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_5"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_5"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_4"
app:layout_constraintEnd_toStartOf="@id/bt_6"
app:layout_constraintTop_toBottomOf="@id/bt_7" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_6"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_6"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_5"
app:layout_constraintEnd_toStartOf="@id/bt_sub"
app:layout_constraintTop_toBottomOf="@id/bt_7" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_sub"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_sub"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_7" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_1"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_1"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_2"
app:layout_constraintTop_toBottomOf="@id/bt_4" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_2"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_2"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_1"
app:layout_constraintEnd_toStartOf="@id/bt_3"
app:layout_constraintTop_toBottomOf="@id/bt_4" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_3"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_3"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_2"
app:layout_constraintEnd_toStartOf="@id/bt_add"
app:layout_constraintTop_toBottomOf="@id/bt_4" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_add"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_add"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_4" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_sign"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_sign"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/bt_0"
app:layout_constraintTop_toBottomOf="@id/bt_1" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_0"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_0"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_sign"
app:layout_constraintEnd_toStartOf="@id/bt_point"
app:layout_constraintTop_toBottomOf="@id/bt_1" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_point"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_point"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_0"
app:layout_constraintEnd_toStartOf="@id/bt_equ"
app:layout_constraintTop_toBottomOf="@id/bt_1" />
<Button
app:layout_constraintHorizontal_weight="1"
android:id="@+id/bt_equ"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="75dp"
android:background="@drawable/calc_bt_selector4"
android:text="@string/bt_equ"
android:textSize="25sp"
app:layout_constraintStart_toEndOf="@id/bt_point"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/bt_1" />
</androidx.constraintlayout.widget.ConstraintLayout>
LinearLayout布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/calc_bg1"
android:orientation="vertical"
android:shrinkColumns="*">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_weight="3"
android:gravity="end|center_vertical"
android:padding="20dp"
android:text="@string/bt_0"
android:textColor="@color/black"
android:textSize="50sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="4">
<Button
android:id="@+id/bt_mc"
android:layout_weight="1"
style="?android:attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mc"
android:textSize="18sp" />
<Button
android:id="@+id/bt_mr"
style="?android:attr/buttonBarStyle"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mr"
android:textSize="18sp" />
<Button
android:id="@+id/bt_mi"
android:layout_weight="1"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mi"
android:textSize="18sp" />
<Button
android:id="@+id/bt_md"
style="?android:attr/buttonBarStyle"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_md"
android:textSize="18sp" />
<Button
android:id="@+id/bt_ms"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_ms"
android:textSize="18sp" />
<Button
android:id="@+id/bt_m"
android:layout_weight="1"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_m"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="4"
android:orientation="horizontal">
<Button
android:id="@+id/bt_p"
android:layout_weight="1"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_p"
android:textSize="25sp" />
<Button
android:id="@+id/bt_ce"
android:layout_weight="1"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_ce"
android:textSize="25sp" />
<Button
android:id="@+id/bt_c"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_c"
android:textSize="25sp" />
<Button
android:id="@+id/bt_x"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_1x"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_1x"
android:textSize="25sp" />
<Button
android:id="@+id/bt_x2"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x2"
android:textSize="25sp" />
<Button
android:id="@+id/bt_12x"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_12x"
android:textSize="25sp" />
<Button
android:id="@+id/bt_div"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_div"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_7"
style="?android:attr/buttonBarStyle"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_7"
android:textSize="25sp" />
<Button
android:id="@+id/bt_8"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_8"
android:textSize="25sp" />
<Button
android:id="@+id/bt_9"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_9"
android:textSize="25sp" />
<Button
android:id="@+id/bt_mut"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_mut"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_4"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_4"
android:textSize="25sp" />
<Button
android:id="@+id/bt_5"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_5"
android:layout_weight="1"
android:textSize="25sp" />
<Button
android:id="@+id/bt_6"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_6"
android:layout_weight="1"
android:textSize="25sp" />
<Button
android:id="@+id/bt_sub"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_sub"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_1"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_1"
android:textSize="25sp" />
<Button
android:id="@+id/bt_2"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_2"
android:textSize="25sp" />
<Button
android:id="@+id/bt_3"
style="?android:attr/buttonBarStyle"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_3"
android:textSize="25sp" />
<Button
android:id="@+id/bt_add"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_add"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_sign"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_sign"
android:textSize="25sp" />
<Button
android:id="@+id/bt_0"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_0"
android:textSize="25sp" />
<Button
android:id="@+id/bt_point"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_point"
android:textSize="25sp" />
<Button
android:id="@+id/bt_equ"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/calc_bt_selector4"
android:text="@string/bt_equ"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
TableLayout布局
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/calc_bg1"
android:shrinkColumns="*">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_weight="3"
android:gravity="end|center_vertical"
android:padding="20dp"
android:text="@string/bt_0"
android:textColor="@color/black"
android:textSize="50sp"
android:textStyle="bold" />
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_mc"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mc"
android:textSize="18sp" />
<Button
android:id="@+id/bt_mr"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mr"
android:textSize="18sp" />
<Button
android:id="@+id/bt_mi"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_mi"
android:textSize="18sp" />
<Button
android:id="@+id/bt_md"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_md"
android:textSize="18sp" />
<Button
android:id="@+id/bt_ms"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_ms"
android:textSize="18sp" />
<Button
android:id="@+id/bt_m"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector1"
android:text="@string/bt_m"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_p"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_p"
android:textSize="25sp" />
<Button
android:id="@+id/bt_ce"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_ce"
android:textSize="25sp" />
<Button
android:id="@+id/bt_c"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_c"
android:textSize="25sp" />
<Button
android:id="@+id/bt_x"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x"
android:textSize="25sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_1x"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_1x"
android:textSize="25sp" />
<Button
android:id="@+id/bt_x2"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_x2"
android:textSize="25sp" />
<Button
android:id="@+id/bt_12x"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_12x"
android:textSize="25sp" />
<Button
android:id="@+id/bt_div"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_div"
android:textSize="25sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_7"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_7"
android:textSize="25sp" />
<Button
android:id="@+id/bt_8"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_8"
android:textSize="25sp" />
<Button
android:id="@+id/bt_9"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_9"
android:textSize="25sp" />
<Button
android:id="@+id/bt_mut"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_mut"
android:textSize="25sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_4"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_4"
android:textSize="25sp" />
<Button
android:id="@+id/bt_5"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_5"
android:textSize="25sp" />
<Button
android:id="@+id/bt_6"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_6"
android:textSize="25sp" />
<Button
android:id="@+id/bt_sub"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_sub"
android:textSize="25sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_1"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_1"
android:textSize="25sp" />
<Button
android:id="@+id/bt_2"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_2"
android:textSize="25sp" />
<Button
android:id="@+id/bt_3"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_3"
android:textSize="25sp" />
<Button
android:id="@+id/bt_add"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector2"
android:text="@string/bt_add"
android:textSize="25sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:id="@+id/bt_sign"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_sign"
android:textSize="25sp" />
<Button
android:id="@+id/bt_0"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_0"
android:textSize="25sp" />
<Button
android:id="@+id/bt_point"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector3"
android:text="@string/bt_point"
android:textSize="25sp" />
<Button
android:id="@+id/bt_equ"
style="?android:attr/buttonBarStyle"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/calc_bt_selector4"
android:text="@string/bt_equ"
android:textSize="25sp" />
</TableRow>
</TableLayout>