Android计算机界面,线性布局嵌套


计算机界面:


  1. 一行只有一个控件,可以不用嵌套线性布局
  2. 控件固定大小,适应性较差
  3. 设置字号textSize用sp为单位
  4. 其中根号可以用ImageButton放个图片
  5. ImageButton是ImageView的之类
  6. 可以查看下面链接设置:
  7. 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>

效果图:

在这里插入图片描述

发布了57 篇原创文章 · 获赞 1 · 访问量 976

猜你喜欢

转载自blog.csdn.net/qq_45844648/article/details/104966264