TableLayout的应用
<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:orientation="vertical"
android:layout_marginTop="20dp">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:gravity="center"
android:background="#ffffef"/>
<Button
android:text="@string/calculate"/>
<TableRow
android:gravity="center"
android:layout_marginTop="8dip">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/seven"
android:layout_column="0"
android:layout_row="2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/eight"
android:layout_column="1"
android:layout_row="2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nine"
android:layout_column="2"
android:layout_row="2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:layout_column="3"
android:layout_row="2"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_marginTop="8dip">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/four"
android:layout_column="0"
android:layout_row="3"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/five"
android:layout_column="1"
android:layout_row="3"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/six"
android:layout_column="2"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:layout_column="3"
android:layout_row="3"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_marginTop="8dip">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/one"
android:layout_column="0"
android:layout_row="4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/two"
android:layout_column="1"
android:layout_row="4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/three"
android:layout_column="2"
android:layout_row="4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:layout_column="3"
android:layout_row="4"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_marginTop="8dip">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:layout_column="0"
android:layout_row="5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="."
android:layout_column="1"
android:layout_row="5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MC"
android:layout_column="2"
android:layout_row="5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:layout_column="3"
android:layout_row="5"/>
</TableRow>
</TableLayout>
</LinearLayout>
浙公网安备 33010602011771号