从头学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开发系列主要以完成实验的过程为主,经常会综合许多知识来写,所以难免会有知识点的交杂,给人一种混乱的感觉. 所以博主推出“重点难点”系列, ...
随机推荐
- Java设计模式学习记录-中介者模式
前言 中介者模式听名字就能想到也是一种为了解决耦合度的设计模式,其实中介者模式在结构上与观察者.命令模式十分相像:而应用目的又与结构模式“门面模式”有些相似.但区别于命令模式的是大多数中介者角色对于客 ...
- 实现一个简单的vue-router
所有项目的源代码都放在我的github上,欢迎大家start: https://github.com/Jasonwang911/my-vue-router 首先来看下vue-router的使用: im ...
- opoa介绍
一 定义 One Page, One Application(后面缩写为OPOA,或者1P1A), 含义很简单:一个页面就是一个应用.不再使用iframe, 页面提交不能再使用submit方 ...
- 【Spring】详解spring事务属性
Spring声明式事务让我们从复杂的事务处理中得到解脱.使得我们再也无需要去处理获得连接.关闭连接.事务提交和回滚等这些操作.再也无需要我们在与事务相关的方法中处理大量的try…catch…final ...
- Spring容器的创建刷新过程
Spring容器的创建刷新过程 以AnnotionConfigApplicationContext为例,在new一个AnnotionConfigApplicationContext的时候,其构造函数内 ...
- GDB使用技巧
最近使用GDB比较多,发现除了最常用的run.break.continue.next等命令的基本用法外,还有一些非常有用的命令和用法,能让你更加得心应手地使用GDB,在这里做了一下简单的总结. 1. ...
- Linux Shell脚本编程while语句案例
1,每隔3秒,打印一次系统负载 #!/bin/bash while true do uptime done 2,把监控结果保存到文件,在后台执行,然后用tail -f监控文件变化 ghostwu@de ...
- 两个inline-block消除间距和对齐(vertical-align)
一.神奇的两个inline-block 很初级的问题,无聊决定写一个故事. 故事的主人公很简单,两个inline-block元素.代码如下,为了看起来简单明了,写得很简陋.效果图如右.发现有两个问题. ...
- Python 简单的远程执行命令
client端执行命令,server端返回命令结果 # server 端 import socket, subprocess sk = socket.socket() address=('127.0. ...
- Python 练习: 简单角色游戏程序
要求: 1.创建三个游戏人物,分别是: 苍井井,女,18,初始战斗力1000 东尼木木,男,20,初始战斗力1800 波多多,女,19,初始战斗力2500 2.游戏场景,分别: 草丛战斗,消耗200战 ...