美文网首页Android开发经验谈Android开发
Android线性布局实现计算机界面

Android线性布局实现计算机界面

作者: 微胖三金 | 来源:发表于2018-10-18 10:58 被阅读76次

1.线性布局实现计算器界面比较简单,主要是布局的嵌套以及layout_weight属性的使用。代码如下所示:

<?xml version="1.0" encoding="utf-8"?>

    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"

    android:orientation="vertical"

    tools:context="com.example04.xx.relativelayout01.MainActivity">

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:hint="0"/>

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="1"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="2"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="3"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="/"/>

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="4"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="5"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="6"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="*"/>

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="7"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="8"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="9"/>

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="-"/>

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:orientation="vertical"

            android:layout_weight="3">

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal">

                    android:layout_width="0dp"

                    android:layout_height="wrap_content"

                    android:text="0"

                    android:layout_weight="2"/>

                    android:layout_width="0dp"

                    android:layout_height="wrap_content"

                    android:text="."

                    android:layout_weight="1"/>

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:text="+"/>

            android:layout_width="0dp"

            android:layout_height="match_parent"

            android:layout_weight="1">

                android:layout_width="match_parent"

                android:layout_height="match_parent"

                android:text="="/>

相关文章

  • Android线性布局实现计算机界面

    1.线性布局实现计算器界面比较简单,主要是布局的嵌套以及layout_weight属性的使用。代码如下所示:

  • Android布局,常用控件

    Android布局以及各自作用 1.LinearLayout实现效果以及属性,权重线性布局 2.RelativeL...

  • Android - 4种基本布局

    1.线性布局 LinearLayout:线性布局 EditText 和 Button 的 android:layo...

  • Android应用界面开发——第二周笔记

    线性布局 线性布局是程序中常见的布局方式之一,包括水平线性布局和垂直线性布局两种, 通过Android:orien...

  • 2020-10-06

    Android常见界面布局:RelativeLayout(相对布局) LinearLayout(线性...

  • 常用的UI布局

    线性布局 http://schemas.android.com/apk/res/android" android:...

  • 基础布局

    Android中的布局 线性布局:LinerLayout 表格布局:TableLayout 相对布局:Relati...

  • Android控件

    vertial 水平horizontal 垂直 布局 : LinearLayout 线性布局android:l...

  • 线性布局(LinearLayout)

    线性布局,顾名思义,指的是整个Android布局中的控件摆放方式是以线性的方式摆放的 线性布局排列方式有: 纵向:...

  • 2018-08-29

    Android基础知识点整理 一、Android六大布局 1.1 LinearLayout线性布局 android...

网友评论

本文标题:Android线性布局实现计算机界面

本文链接:https://www.haomeiwen.com/subject/geejzftx.html