Android中的布局

2023-05-16

In this tutorial you will learn about different layouts in android.

在本教程中,您将了解android中的不同布局。

Android layouts are used to define the visual structure of user interface. The UI components like label, button, textbox, etc. are defined inside a layout. So before designing UI for an android application you must know about different layouts available in android.

Android布局用于定义用户界面的视觉结构。 UI组件(如标签,按钮,文本框等)在布局内定义。 因此,在为Android应用程序设计UI之前,您必须了解android中可用的不同布局。

There are two ways to design UI in android.

有两种方法可以在android中设计UI。

  • Using XML file

    使用XML档案

  • Using Java code at run time

    在运行时使用Java代码

Designing layout using XML file is better because the presentation of the app is kept separate from the code that controls the behavior. By doing this the debugging and alteration in UI becomes easier. The layout XML files are placed inside res/layout folder.

使用XML文件设计布局会更好,因为应用程序的表示与控制行为的代码是分开的。 这样,UI中的调试和更改变得更加容易。 布局XML文件放置在res / layout文件夹中。

Android中的布局类型 (Types of Layouts in Android)

The various layouts that are available in android are given below. Here I am giving a brief introduction of each layout. I will explain them in detail with example in upcoming tutorials.

以下列出了android中可用的各种布局。 在这里,我简要介绍每种布局。 我将在以后的教程中通过示例详细解释它们。

线性布局 (Linear Layout)

As its name indicates, Linear Layout is used to arrange its children in linear manner, either vertically or horizontally.

顾名思义,线性布局用于以垂直或水平线性方式排列其子级。

相对布局 (Relative Layout)

This layout is used to place child views relative to each other. We can specify the position of each view or layout relative to sibling or parent.

此布局用于相对于彼此放置子视图。 我们可以指定每个视图或布局相对于同级或父级的位置。

桌子布局 (Table Layout)

This layout is used to arrange the child views into rows and columns.

此布局用于将子视图排列为行和列。

绝对布局 (Absolute Layout)

Absolute Layout is used to specify the exact locations of its children in x and y coordinates.

绝对布局用于在x和y坐标中指定其子级的确切位置。

框架布局 (Frame Layout)

This layout is designed to block out an area on the screen to display a single view.

此布局旨在遮挡屏幕上的某个区域以显示单个视图。

标签布局 (Tab Layout)

It provides a horizontal layout to display tabs.

它提供了用于显示选项卡的水平布局。

列表显示 (List View)

It is used to display a list of vertically scrollable items.

它用于显示垂直可滚动项目的列表。

网格视图 (Grid View)

It is used to display items in two-dimensional scrolling grid.

它用于在二维滚动网格中显示项目。

If you found any mistake or have doubts regarding above layouts in android tutorial then feel free to mention it by commenting below.

如果您在Android教程中对上述布局有任何错误或疑问,请随时在下面评论中提及。

翻译自: https://www.thecrazyprogrammer.com/2015/12/layouts-in-android.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android中的布局 的相关文章

随机推荐

  • 【教程向】通过windows在树莓派3B上安装Ubuntu MATE 16.04.2 (Xenial)

    本文参考了http www ituring com cn article 273613 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 6
  • Docker无介绍快使用,docker拉取rabbitmq(十三)

    Docker无介绍快使用 xff0c docker拉取rabbitmq xff08 十三 xff09 问题背景Docker无介绍快使用 xff0c 安装部署hello测试 xff08 一 xff09 Docker无介绍快使用 xff0c d
  • 【ROS2&AI】电脑摄像头、intel-D435,利用ros2发布订阅图像(Python)

    本文欲分享两个代码来实现图像的传输 xff0c 利用ros2 xff0c ROS2 xff5e 配置 xff1a Ubuntu20 04 Python ROS2 foxy opencv xff1b 电脑相机 or Intel D435相机
  • 2021年嵌入式面试题汇总(最新经典)

    写在前面 xff1a 秋招嵌入式开发方向 xff0c 经过了很多场的笔试与面试 xff0c 在准备的过程中看了非常多的资料 xff0c 现在把他们整理一下 xff0c 有的资料看过了觉得不错就保存下来了 xff0c 如果有不对的地方 xff
  • 垂直起降无人机 Gazebo + PX4 HITL simulation

    环境 xff1a ubuntu版本 xff1a 20 04 px4固件版本 xff1a stable v1 12 3 QgroundControl版本 xff1a v4 14 飞控硬件 xff1a pixhawk cuav v5 43 ga
  • PX4飞控源码L1制导律详解

    PX4飞控源码L1制导律详解 本文目的在于帮助大家看清楚L1制导律选择参考点的策略 xff0c 所以作者将与L1知道无关的代码添加删除线 所有以下划线开头的变量在PX4中都是全局变量 xff0c 在下面的函数中 xff0c 有 target
  • Ubuntu下PX4飞控开发环境搭建

    双清微电子 前言 xff1a PX4支持Pixhawk pixracer 高通骁龙飞控板 树莓派 派诺特等硬件 PX4是构建在Nuttx实时操作系统上的 第一步 xff1a 安装Linux基础软件 第二步 xff1a 下载源代码 第三步 安
  • 开源飞控APM/PX4的发展史

    开源 Open Source 的概念最早被应用于软件 xff0c 开放源代码促进会 Open Source Initiative 用其描述那些源码可以被公众使用的软件 xff0c 并且此软件的使用 修改和发行也不受许可证的限制 每一个开源项
  • Mexican lolita ghds sale images

    The clip on hair extensions are available cheap ghd a variety of different colors and lengths will be the very best choi
  • python 获取当前文件路径

    一 Python 获取当前文件路径方法 sys path 0 获取文件当前工作目录路径 绝对路径 sys argv 0 获得模块所在的路径 由系统决定是否是全名 若显示调用python指令 xff0c 如python demo py xff
  • C#下使用RealSense D435i获取图像,深度,导出.ply点云

    首先需要在NuGet管理中安装RealSense库相关包 主要安装下面两个包 xff1a 代码中引入 xff1a using Intel RealSense 配置相机 var cfg 61 new Config using var ctx
  • 小觅的简单代码程序实现

    96 from future import print function import os import sys PY DIR 61 os path dirname os path dirname os path abspath file
  • TCP 服务器程序突然中断 由于send函数导致

    最近在写tcp 客户端服务器操作 设置服务器为单线程多个客户端连入 开发过程中出现 服务器代码运行过程中 在send处突然中断情况 通过GDB调试发现send函数报错提示打开文件错误 由于测试过程纵单节点反复连入客户端 在client so
  • 从高考到程序员

    从高考到程序员 说真的 xff0c 我做梦也没有想到我会去做程序员 xff0c 一个高中我一直不敢也不想碰到的职业 然而 xff0c 我现在却成为了一位程序员 xff0c 有时候 xff0c 人生真的有点戏剧性 上高中时的我对未来真的是没有
  • 关于单链表的理解

    链表是一种物理 存储单元上非连续 非顺序的 存储结构 xff0c 数据元素的逻辑顺序是通过链表中的 指针链接次序实现的 链表由一系列结点 xff08 链表中每一个元素称为结点 xff09 组成 xff0c 结点可以在运行时动态生成 每个结点
  • rc1改为rc2出现的问题1

    同样的代码 xff0c 在rc1运行时正常 xff0c 在rc2第一次运行正常 xff08 控制台比rc1输出了好多信息 xff09 xff0c 再次运行时抛出异常后退出 java 代码 2007 8 8 13 09 26 net jxta
  • 对倒立摆的LQR控制

    1 问题建模 首先对待研究的问题建立数学模型 在倒立摆模型分析这篇文章里 xff0c 我们已经做了完整的受力分析 最终得到了关于系统变量的微分方程 M 43 m
  • 如何在VirtualBox中使用分支快照

    VirtualBox has supported virtual machine VM snapshots for a while However until version 3 1 it was only possible to reve
  • onmouseover(HTML元素)

    描述 Description The onmouseover attribute is one of the most commonly used event attributes It captures the moment that a
  • Android中的布局

    In this tutorial you will learn about different layouts in android 在本教程中 xff0c 您将了解android中的不同布局 Android layouts are use