从头学Android之RelativeLayout相对布局
http://blog.csdn.net/worker90/article/details/6893246
相对布局对于做Web开发来说再熟悉不过了,我们在用CSS+DIV的时候经常会用到这些类似的相对布局的,在设置某个DIV的位置的时候,我们时常会以一个DIV作为参考来设置的位置,废话不多说,直接看属性看实例。
属性名称 |
描述 |
android:layout_below |
摆放在指定组件的下边 |
android:layout_toLeftOf |
摆放在指定组件的左边 |
android:layout_toRightOf |
摆放在指定组件的右边 |
android:layout_alignTop |
以指定组件作为参考进行上对齐 |
android:layout_algnBottom |
以指定组件作为参照进行下对齐 |
android:layout_alignLeft |
以指定组件作为参考进行左对齐 |
android:layout_alignRight |
以指定组件 |
以上一节的例子再做一个相对布局实现的例子
相对布局对于做Web开发来说再熟悉不过了,我们在用CSS+DIV的时候经常会用到这些类似的相对布局的,在设置某个DIV的位置的时候,我们时常会以一个DIV作为参考来设置的位置,废话不多说,直接看属性看实例。
属性名称 |
描述 |
android:layout_below |
摆放在指定组件的下边 |
android:layout_toLeftOf |
摆放在指定组件的左边 |
android:layout_toRightOf |
摆放在指定组件的右边 |
android:layout_alignTop |
以指定组件作为参考进行上对齐 |
android:layout_algnBottom |
以指定组件作为参照进行下对齐 |
android:layout_alignLeft |
以指定组件作为参考进行左对齐 |
android:layout_alignRight |
以指定组件 |
以上一节的例子再做一个相对布局实现的例子
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:layout_toRightOf="@+id/tv_username"
android:id="@+id/txt_username">
</EditText>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/txt_username"
android:layout_alignLeft="@+id/txt_username"
android:layout_alignParentRight="true" android:id="@+id/txt_password"></EditText>
<TextView android:id="@+id/tv_username" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="用户名称"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_marginTop="14dp"></TextView>
<Button android:text="登录" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/txt_password"
android:layout_alignParentRight="true" android:layout_alignLeft="@+id/txt_password"
android:id="@+id/btn_login"></Button>
<Button android:text="取消" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/txt_password"
android:layout_alignRight="@+id/tv_username" android:id="@+id/btn_cacel"></Button>
<TextView android:id="@+id/tv_password" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="用户密码"
android:layout_centerVertical="true" android:layout_toLeftOf="@+id/txt_password"></TextView>
</RelativeLayout>
实例效果:
实例效果:
从头学Android之RelativeLayout相对布局的更多相关文章
- 从零開始学android<RelativeLayout相对布局.十六.>
相对布局管理器指的是參考某一其它控件进行摆放,能够通过控制,将组件摆放在一个指定參考组件的上.下.左.右等位置,这些能够直接通过各个组件提供的属性完毕. 以下介绍一下各个方法的基本使用 No. 属性名 ...
- 从头学Android系列
从头学Android系列 http://blog.csdn.net/worker90/article/category/888358
- 从头学Android之Android布局管理:LinerLayout线性布局
LinerLayout线性布局: 这种布局方式是指在这个里面的控件元素显线性,我们可以通过setOrientation(int orientation)来指定线性布局的显示方式,其值有:HORIZON ...
- 从零開始学android<使用嵌套布局实现计算器界面.十七.>
所谓的嵌套布局就是在一个文件里嵌套多个布局文件 <span style="font-size:18px;"> <LinearLayout android:layo ...
- 23、从头学Android之ContentProvider .
http://blog.csdn.net/jiahui524/article/details/7016430 应用场景: 在Android官方指出的Android的数据存储方式总共有五种,分别是:Sh ...
- Android之RelativeLayout相对布局
1.相关术语解释 1.基本属性 gravity :设置容器内组件的对齐方式 ignoreGravity : 设置该属性为true的组件,将不受gravity属性的影响 2.根据父容器定位 layout ...
- 一步一步学android之布局管理器——RelativeLayout
今天开始学习RelativeLayout(相对布局),相对布局在平时布局的时候用的较多,因为Android适配方面的原因.相对布局可以控制组件摆放的位置(放在任一组件的上下左右等位置),下面来看看类的 ...
- 第13章、布局Layouts之RelativeLayout相对布局(从零開始学Android)
RelativeLayout相对布局 RelativeLayout是一种相对布局,控件的位置是依照相对位置来计算的,后一个控件在什么位置依赖于前一个控件的基本位置,是布局最经常使用,也是最灵活的一种布 ...
- Android开发重点难点1:RelativeLayout(相对布局)详解
前言 啦啦啦~博主又推出了一个新的系列啦~ 之前的Android开发系列主要以完成实验的过程为主,经常会综合许多知识来写,所以难免会有知识点的交杂,给人一种混乱的感觉. 所以博主推出“重点难点”系列, ...
随机推荐
- 利用cordova打包H5混合app
1.首先布置jdk环境,下载jdk(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm ...
- Angular2入门:TypeScript的类型 - let , var, const
一.let 二.const
- JavaWeb学习 (十一)————Session
一.Session简单介绍 在WEB开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占一个session对象(默认情况下).因此,在需要保存用户数据时,服务 ...
- Vim 匹配相同的单词并高亮
将光标移动到要匹配的单词处: "g + d" :高亮显示所有相同的单词 shift + "*" :向下查找相同单词并高亮显示 shift + "#&q ...
- ssm简单整合(注释方法)
1.创建web工程,选择web.xml文件,并导入相关jar包(使用的spring4.0以上版本,) 2.配置web.xml文件,包括spring.xml,springMVC.xml的加载映射,核心操 ...
- java_单词长度
题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以‘.’结束.你要输出这行文本中每个单词的长度.这里的单词与语言无关,可以包括各种符号,比如“it's”算一个单词,长度为4.注意,行中 ...
- How to Find the Standard Deviation in Minitab
Standard deviation, represented by the Greek Letter sigma σ, is a measure of dispersement in statist ...
- 通过webpack2从0开始配置自己的vue项目 1
PS 阅读者需要node基础.webpack原理知识.vue基础 安装node 这个网上很多教程 打开终端 创建项目 npm init 全局安装: cnpm i webpack webpack-dev ...
- form的重置reset
HTML中Form表单的reset方法被用来重置用户所输入的内容,以前一直误以为其是单纯的将input等输入项中的值清空. 但实际上不是这样的,reset方法的本质是将input等输入项中的内容还原为 ...
- Apex简介
Apex特点 Salesforce为开发者提供了Apex语言.它是一种语法上类似于Java的编程语言,有以下特点: 面向对象 完全在云端处理,包括保存.编译.执行 强类型 大小写不敏感(这一点和其他大 ...