计算机界面:
- 一行只有一个控件,可以不用嵌套线性布局
- 控件固定大小,适应性较差
- 设置字号textSize用sp为单位
- 其中根号可以用ImageButton放个图片
- ImageButton是ImageView的之类
- 可以查看下面链接设置:
- https://editor.csdn.net/md?articleId=104966942
添加链接描述
<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"
tools:context=".MainActivity"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/jyjsj"
android:textSize="@dimen/activity_jyjsj"
android:layout_marginTop="10dp"
android:gravity="center"
android:layout_weight="1"
/>
<!-- 设置文本框不可编辑: android:focusable="false"
,不可粘贴:
,最大行数为1: android:maxLines="1"
,
-->
<EditText
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/shape_radius"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:id="@+id/et_sz"
android:maxLines="1"
android:textSize="25sp"
android:focusable="false"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/ce"
android:textSize="30sp"
android:text="@string/ce"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/chu"
android:textSize="30sp"
android:text="@string/chu"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/cheng"
android:textSize="30sp"
android:text="@string/cheng"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/c"
android:textSize="30sp"
android:text="@string/c"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/seven"
android:textSize="30sp"
android:text="@string/seven"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/eight"
android:textSize="30sp"
android:text="@string/eight"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/nine"
android:textSize="30sp"
android:text="@string/nine"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/jia"
android:textSize="30sp"
android:text="@string/jia"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/four"
android:textSize="30sp"
android:text="@string/four"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/five"
android:textSize="30sp"
android:text="@string/five"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/six"
android:textSize="30sp"
android:text="@string/six"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/jian"
android:textSize="30sp"
android:text="@string/jian"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/one"
android:textSize="30sp"
android:text="@string/one"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/two"
android:textSize="30sp"
android:text="@string/two"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/three"
android:textSize="30sp"
android:text="@string/three"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/genhao"
android:textSize="30sp"
android:text="@string/genhao"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<Button
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:id="@+id/zero"
android:textSize="30sp"
android:text="@string/zero"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/dian"
android:textSize="30sp"
android:text="@string/dian"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/denghao"
android:textSize="30sp"
android:text="@string/denghao"
/>
</LinearLayout>
</LinearLayout>
效果图: