【Android】UI布局之线性布局(登录界面代码)
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布局之线性布局(登录界面代码)相关推荐
- android线性布局设置控件固定在底部,Android UI组件LinearLayout线性布局详解
LinearLayout 线性布局,该布局的继承关系: 1. 什么是线性布局 通俗的说感觉起来和线有关,参照线的特点,有么是横向的,要么是竖向的. LinearLayout是线性布局控件,它包含的子控 ...
- Android布局之线性布局LinearLayout(二) ----简单模仿ios端小米计算器主界面UI
Android布局之线性布局LinearLayout(二) ----简单模仿ios端小米计算器主界面UI 今天老师的要求是让用LinearLayout布局做自己手机自带的计算器的UI设计,因为io ...
- 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 布局的创 ...
- Android UI详解之布局管理器(一)
Android UI详解之布局管理器 一.布局管理器 ①顶级父类View ②子类GroupView ③AbsoluteLayout.FrameLayout.LinearLayout.GridLayou ...
- android表格布局bottom,Android基础_2 Activity线性布局和表格布局
在activity的布局中,线性布局和表格布局是最简单的,这次分别从线性布局,表格布局以及线性布局和表格混合布局做了实验,实验中只需要编写 相应的xml的代码,java代码不需要更改,因为我们这里只是 ...
- Android布局——Linearlayout线性布局
Android最简单最常用的LinearLayout线性布局 一.认识LinearLayout 线性布局是Android中较为常用的布局方式,使用LinearLayout标签.线性布局主要有两种形式, ...
- android布局之线性布局
LinearLayout 线性布局有两种,分别是水平线性布局和垂直线性布局,LinearLayout属性中android:orientation为设置线性布局当其="vertical&quo ...
- 安卓六大布局之 线性布局(LinearLayout)
Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面. Android的六大布局分别是 LinearL ...
- 给我一个web前端的登录界面代码
下面是一份简单的 HTML 和 CSS 登录界面代码示例: <!DOCTYPE html> <html><head><meta charset="u ...
最新文章
- 进fastreboot
- exe打包工具_pyqt5快速上手基础篇12-使用Pyinstaller打包应用程序
- node.js编程错误记录集
- 根本无处可避的广东三游
- 如何优雅的处理异常(java)
- mysql 8.0 ga_mysql 8.0 GA发布了
- 动物识别专家系统python_5G、AI、Python、区块链,看2019上半年这10本技术新书就够了...
- POJ 1201 Intervals(差分约束)
- Java+spring+springmvc 基于ssm的交通事故档案管理系统#毕业设计
- golang学习之五:error、painc、recover
- 计算机病毒为了隐藏,识别计算机病毒的方法
- 关于移动互联网运营的分享总结
- android studio找不到app moudle和project moudle
- /sys/class/gpio 操作方法
- TCP/IP五层协议体系结构的各层功能
- 最新项目管理软考中级易错内容整理-终结篇
- 【题解】poj1738石子合并 区间DP 加西亚瓦克斯算法
- 精通iOS开发(第5版)
- 高校人员信息管理系统(Java课程设计,带图形界面版)
- 基于深度学习的视频检测(三) 目标跟踪