计算器布局

来源:互联网 发布:幼儿园淘宝活动方案 编辑:程序博客网 时间:2024/05/20 03:07

这里写图片描述

布局做个记录吧

<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.jane.simplecalculator.MainActivity">    <TableRow        android:layout_width="match_parent"        android:layout_gravity="center"        android:layout_weight="1">        <EditText            android:id="@+id/output"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:gravity="right|center_vertical"            android:lines="1"            android:textSize="48sp"            android:layout_weight="1"            android:background="@color/green"/>    </TableRow>    <TableRow        android:layout_weight="1"        android:gravity="center">        <LinearLayout android:layout_weight="4"            android:layout_height="match_parent">            <Button                android:id="@+id/one"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="1"                android:textSize="30sp"/>            <Button                android:id="@+id/two"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="2"                android:textSize="30sp"/>            <Button                android:id="@+id/three"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="3"                android:textSize="30sp"/>            <Button                android:id="@+id/plus"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="+"                android:textSize="30sp"/>        </LinearLayout>    </TableRow>    <TableRow    android:layout_weight="1"        android:gravity="center">    <LinearLayout        android:layout_height="match_parent"        android:layout_weight="4">        <Button            android:id="@+id/four"            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="1"            android:text="4"            android:textSize="30sp"/>        <Button            android:id="@+id/five"            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="1"            android:text="5"            android:textSize="30sp"/>        <Button            android:id="@+id/six"            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="1"            android:text="6"            android:textSize="30sp"/>        <Button            android:id="@+id/subtract"            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="1"            android:text="-"            android:textSize="30sp"/>    </LinearLayout></TableRow>    <TableRow        android:layout_weight="1"        android:gravity="center">        <LinearLayout            android:layout_height="match_parent"            android:layout_weight="4">            <Button                android:id="@+id/seven"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="7"                android:textSize="30sp"/>            <Button                android:id="@+id/eight"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="8"                android:textSize="30sp"/>            <Button                android:id="@+id/nine"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="9"                android:textSize="30sp"/>            <Button                android:id="@+id/multiply"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="*"                android:textSize="30sp"/>        </LinearLayout>    </TableRow>    <TableRow        android:layout_weight="1"        android:gravity="center">        <LinearLayout            android:layout_height="match_parent"            android:layout_weight="4">            <Button                android:id="@+id/clear"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="清空"                android:textSize="30sp"/>            <Button                android:id="@+id/zero"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="0"                android:textSize="30sp"/>            <Button                android:id="@+id/equal"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="="                android:textSize="30sp"/>            <Button                android:id="@+id/divide"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_weight="1"                android:text="/"                android:textSize="30sp"/>        </LinearLayout>    </TableRow></TableLayout>
0 0
原创粉丝点击