当前位置:   article > 正文

安卓开发学习之设计三种计算机界面_android设计计算器实现界面跳转

android设计计算器实现界面跳转

请设计下面的三种计算器的UI:

1.简单的计算器
在这里插入图片描述

2.科学计算器
在这里插入图片描述

3.程序计算器
在这里插入图片描述
不用实现具体功能,只需设计界面即可!

为了更好的在三个界面之间跳转,添加一个主界面。

activity_main.xml

线性布局中添加4个按钮

<?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=".MainActivity">


    <LinearLayout
        android:layout_width="431dp"
        android:layout_height="669dp"
        android:orientation="vertical"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="-4dp"
        tools:layout_editor_absoluteY="57dp">


        <Button
            android:id="@+id/button21"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="简单计算器" />

        <Button
            android:id="@+id/button22"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="科学计算器" />

        <Button
            android:id="@+id/button23"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="程序计算器" />

        <Button
            android:id="@+id/button24"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="退出" />

    </LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
界面效果:

在这里插入图片描述

简单计算器:

chengxujishuanqi.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"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="7">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center|right"
            android:text="0"
            android:textSize="50sp" />

    </LinearLayout>

    <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/button1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="退格"
            android:textSize="30sp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="清除"
            android:textSize="30sp" />

        <Button
            android:id="@+id/button3"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="±"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button4"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="+"
            android:textSize="40sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="4">

        <Button
            android:id="@+id/button5"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="7"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button6"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="8"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button7"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="9"
            android:textSize="40sp" />

        <Button
            android:id="@+id/button8"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text=""
            android:textSize="40sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="4">

        <Button
            android:id="@+id/button9"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="4"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button10"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="5"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button11"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="6"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button12"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="*"
            android:textSize="40sp"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="4">

        <Button
            android:id="@+id/button13"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="1"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button14"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="2"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button15"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="3"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button16"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/"
            android:textSize="40sp"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="4">

        <Button
            android:id="@+id/button17"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="0"
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button18"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="."
            android:textSize="40sp"/>

        <Button
            android:id="@+id/button19"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="1/x"
            android:textSize="30sp"/>

        <Button
            android:id="@+id/button20"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="="
            android:textSize="40sp"/>
    </LinearLayout>

</LinearLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
界面效果:

在这里插入图片描述

科学计算器:

kexuejishuanqi.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center|right"
            android:text="0"
            android:textSize="50sp"/>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="21dp"
            android:layout_margin="10dp"
            android:padding="0dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RadioGroup
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="角度"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="弧度"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="梯度"
                        android:textSize="15dp" />
                </RadioGroup>
            </TableRow>

        </TableLayout>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="215dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="SIN" />

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="COS" />

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="TAN" />

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="COT"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ASIN"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ACOS"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ATAN"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ACOT"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="SINH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="COSH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="TANH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="COTH"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ASINH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ACOSH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ATANH"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="ACOTH"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="LN"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="LOG10"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="N!"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="X^Y"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="E^X"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="π"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="("></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text=")"></Button>


            </TableRow>


        </TableLayout>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="186dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="退格"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="清除"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="±"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="+"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="7"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="8"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="9"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="-"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="4"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="5"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="6"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="*"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="1"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="2"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="3"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="/"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="0"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="."></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="1/X"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="="></Button>


            </TableRow>


        </TableLayout>

    </LinearLayout>

</LinearLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
界面效果:

在这里插入图片描述

程序计算器:

chengxujishuanqi.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center|right"
            android:text="0"
            android:textSize="50sp" />

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="21dp"
            android:layout_margin="10dp"
            android:padding="0dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RadioGroup
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <RadioButton
                        android:layout_width="76dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="十六进制"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="二进制"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="八进制"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="十进制"
                        android:textSize="15dp" />
                </RadioGroup>
            </TableRow>

        </TableLayout>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="21dp"
            android:layout_margin="10dp"
            android:padding="0dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RadioGroup
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="八字节"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="四字节"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="二字节"
                        android:textSize="15dp" />

                    <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="单字节"
                        android:textSize="15dp" />
                </RadioGroup>
            </TableRow>

        </TableLayout>


        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:columnCount="4"
            android:orientation="horizontal"
            android:rowCount="3">

            <Button
                android:layout_width="102dp"
                android:layout_height="match_parent"
                android:text="NOT"
                android:textColor="#FBF9F9" />

            <Button
                android:layout_width="103dp"
                android:layout_height="match_parent"
                android:text="AND" />

            <Button
                android:layout_width="104dp"
                android:layout_height="match_parent"
                android:text="OR" />

            <Button
                android:layout_width="99dp"
                android:layout_height="match_parent"
                android:text="XOR" />

            <Button
                android:layout_width="104dp"
                android:layout_height="match_parent"
                android:text="循环左移" />

            <Button
                android:layout_width="104dp"
                android:layout_height="match_parent"
                android:text="循环右移" />

            <Button
                android:layout_width="104dp"
                android:layout_height="match_parent"
                android:text="左移" />

            <Button
                android:layout_width="102dp"
                android:layout_height="match_parent"
                android:text="MOD" />

            <Button
                android:layout_columnSpan="2"
                android:layout_gravity="fill"
                android:text="无符号右移" />

            <Button
                android:layout_width="wrap_content"
                android:layout_columnSpan="2"
                android:layout_gravity="fill"
                android:text="有符号右移" />


        </GridLayout>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="212dp">

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="退格"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="清除"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="9"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="±"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="6"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="7"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="8"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="+"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="3"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="4"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="5"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="+"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="0"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="1"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="2"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="/"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="A"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="B"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="C"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="D"></Button>


            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="487dp"
                android:layout_weight="1"
                android:padding="0dp">

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="E"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="F"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="G"></Button>

                <Button
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="="></Button>


            </TableRow>



        </TableLayout>

    </LinearLayout>

</LinearLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
界面效果:

在这里插入图片描述

主界面和其他界面的交互

点击对应的按钮,跳转相应的界面!

MainActivity
package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn1=(Button) findViewById(R.id.button21);
        Button btn2=(Button) findViewById(R.id.button22);
        Button btn3=(Button) findViewById(R.id.button23);
        Button btn4=(Button) findViewById(R.id.button24);
        btn1.setOnClickListener(new View.OnClickListener(){
            @Override
            public  void onClick(View View){
                setContentView(R.layout.jiandanjishuanqi);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener(){
            @Override
            public  void onClick(View View){
                setContentView(R.layout.kexuejishuanqi);
            }
        });
        btn3.setOnClickListener(new View.OnClickListener(){
            @Override
            public  void onClick(View View){
                setContentView(R.layout.chengxujishuanqi);
            }
        });
        btn4.setOnClickListener(new View.OnClickListener(){
                @Override
                public  void onClick(View View){
                    System.exit(0);
        }

        });
    }
    @Override
    public  boolean onKeyDown(int keyCode, KeyEvent event){
        if(keyCode==KeyEvent.KEYCODE_BACK){
            Intent intent=new Intent(this,MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
        return  true;
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

总结:

安卓实验作业,刚接触能力有限就做了个大概,可以根据自己的需求添加主题,样式,颜色!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/271982
推荐阅读
相关标签
  

闽ICP备14008679号