1、布局管理

组件在activity中呈现的方式,包含组件大小、间距、对齐方式

Android提供了两种布局的实现方式:

  • .在xml配置文件中声明,通过setContentView(R.layout.main)方法呈现在activity中,通过findViewById()方法获得组件实例。(一般推荐这种方式)
  • 动态生成组件以及设置相关布局

2、线性布局 LinearLayout

线性布局是最简单的一种布局,将子组件按照垂直或者水平方向进行布局。

  • 方向控制:android:orientation属性来控制,有vertical(垂直)和horizontal(水平)两种
  • 对齐方式:android:gravity属性来控制,有top、bottom、left、right、center等
  • 比例分割:weight

3、登录界面

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/textView1"android:layout_width="13dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="username:"android:layout_marginLeft="15dp"/><EditTextandroid:id="@+id/editText1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="2"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/textView2"android:layout_width="13dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="password:"android:layout_marginLeft="15dp"/><EditTextandroid:id="@+id/editText2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="2"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:id="@+id/button1"android:layout_width="160dp"android:layout_height="wrap_content"android:layout_marginLeft="45dp"android:layout_marginRight="10dp"android:text="submit" /><Buttonandroid:id="@+id/button2"android:layout_width="160dp"android:layout_height="wrap_content"android:layout_marginRight="15dp"android:text="reset" /></LinearLayout>
</LinearLayout>

【Android】UI布局之线性布局(登录界面代码)相关推荐

  1. android线性布局设置控件固定在底部,Android UI组件LinearLayout线性布局详解

    LinearLayout 线性布局,该布局的继承关系: 1. 什么是线性布局 通俗的说感觉起来和线有关,参照线的特点,有么是横向的,要么是竖向的. LinearLayout是线性布局控件,它包含的子控 ...

  2. Android布局之线性布局LinearLayout(二) ----简单模仿ios端小米计算器主界面UI

    Android布局之线性布局LinearLayout(二) ----简单模仿ios端小米计算器主界面UI   今天老师的要求是让用LinearLayout布局做自己手机自带的计算器的UI设计,因为io ...

  3. Android 开发 -- 开发第一个安卓程序、Android UI开发(布局的创建:相对布局和线性布局、控件单位:px pt dp sp、常用控件 、常见对话框、ListView)

    文章目录 1. 开发第一个Hello World程序 1.1 开发程序 1.2 认识程序中的文件 1.3 Android程序结构 1.4 安卓程序打包 2. Android UI开发 2.1 布局的创 ...

  4. Android UI详解之布局管理器(一)

    Android UI详解之布局管理器 一.布局管理器 ①顶级父类View ②子类GroupView ③AbsoluteLayout.FrameLayout.LinearLayout.GridLayou ...

  5. android表格布局bottom,Android基础_2 Activity线性布局和表格布局

    在activity的布局中,线性布局和表格布局是最简单的,这次分别从线性布局,表格布局以及线性布局和表格混合布局做了实验,实验中只需要编写 相应的xml的代码,java代码不需要更改,因为我们这里只是 ...

  6. Android布局——Linearlayout线性布局

    Android最简单最常用的LinearLayout线性布局 一.认识LinearLayout 线性布局是Android中较为常用的布局方式,使用LinearLayout标签.线性布局主要有两种形式, ...

  7. android布局之线性布局

    LinearLayout 线性布局有两种,分别是水平线性布局和垂直线性布局,LinearLayout属性中android:orientation为设置线性布局当其="vertical&quo ...

  8. 安卓六大布局之 线性布局(LinearLayout)

    Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面. Android的六大布局分别是 LinearL ...

  9. 给我一个web前端的登录界面代码

    下面是一份简单的 HTML 和 CSS 登录界面代码示例: <!DOCTYPE html> <html><head><meta charset="u ...

最新文章

  1. 进fastreboot
  2. exe打包工具_pyqt5快速上手基础篇12-使用Pyinstaller打包应用程序
  3. node.js编程错误记录集
  4. 根本无处可避的广东三游
  5. 如何优雅的处理异常(java)
  6. mysql 8.0 ga_mysql 8.0 GA发布了
  7. 动物识别专家系统python_5G、AI、Python、区块链,看2019上半年这10本技术新书就够了...
  8. POJ 1201 Intervals(差分约束)
  9. Java+spring+springmvc 基于ssm的交通事故档案管理系统#毕业设计
  10. golang学习之五:error、painc、recover
  11. 计算机病毒为了隐藏,识别计算机病毒的方法
  12. 关于移动互联网运营的分享总结
  13. android studio找不到app moudle和project moudle
  14. /sys/class/gpio 操作方法
  15. TCP/IP五层协议体系结构的各层功能
  16. 最新项目管理软考中级易错内容整理-终结篇
  17. 【题解】poj1738石子合并 区间DP 加西亚瓦克斯算法
  18. 精通iOS开发(第5版)
  19. 高校人员信息管理系统(Java课程设计,带图形界面版)
  20. 基于深度学习的视频检测(三) 目标跟踪

热门文章

  1. simulate_screencap
  2. 面试百度新浪头条b站阿里的研发实习生面试记录
  3. ubuntu 单网卡 安装lede作旁路由
  4. 深入CORS:历史,工作原理和最好的例子
  5. ic卡写卡 angus_使用Angus更快地构建Web应用程序
  6. Papervision3D拖动物体
  7. Oracle之条件模糊匹配
  8. 电解电容使用久了电容量真的会下降吗?
  9. 查看SCI期刊引用格式步骤记录
  10. pytesseract 提高印刷体数字识别率走的弯路 白底黑字