AndroidStudio编写简易计算器App(Java语⾔版)Android Studio 编写简易计算器App (Java语⾔版)
效果演⽰
布局⽂件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android="schemas.android/apk/res/android"
orientation="vertical"layout_width="match_parent"
layout_height="match_parent">
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="2"
orientation="vertical">
<TextView
id="@+id/mini"
layout_width="match_parent"
layout_height="wrap_content"
textSize="40dp"
textSize="40dp"
text=""
textDirection="rtl"/>
<TextView
id="@+id/max"
layout_width="match_parent"
layout_height="wrap_content"
textSize="100dp"
text=""
textDirection="rtl"/>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="%"
textSize="30dp"
onClick="surplus"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="CE"
textSize="30dp"
onClick="clearce"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="C"
textSize="30dp"
onClick="clearc"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="⇦"
textSize="30dp"
onClick="backsprce"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_width="match_parent"
layout_height="match_parent"
text="1/x"
textSize="30dp"
onClick="reciprocal"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="x²"
textSize="30dp"
onClick="square"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="²√x"
textSize="30dp"
onClick="squareroot"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="÷"
textSize="60dp"
onClick="division"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="7"
textSize="30dp"
onClick="number_7"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="8"
textSize="30dp"
onClick="number_8"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
<Button
layout_width="match_parent"
layout_height="match_parent"
text="9"
textSize="30dp"
onClick="number_9"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="×"
textSize="30dp"
onClick="multiplication"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="4"
textSize="30dp"
onClick="number_4"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="5"
textSize="30dp"
onClick="number_5"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="6"
textSize="30dp"怎么用java编写app软件
onClick="number_6"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="-"
textSize="30dp"
onClick="subtraction"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="1"
textSize="30dp"
onClick="number_1"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="2"
textSize="30dp"
onClick="number_2"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="3"
textSize="30dp"
onClick="number_3"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="+"
textSize="30dp"
onClick="addition"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
layout_width="match_parent"
layout_height="0dp"
layout_weight="1"
orientation="horizontal">
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
text="±"
textSize="30dp"
onClick="change"/>
</LinearLayout>
<LinearLayout
layout_width="wrap_content"
layout_height="match_parent"
layout_weight="1">
<Button
layout_width="match_parent"
layout_height="match_parent"
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论