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相对布局的更多相关文章

  1. 从零開始学android&lt;RelativeLayout相对布局.十六.&gt;

    相对布局管理器指的是參考某一其它控件进行摆放,能够通过控制,将组件摆放在一个指定參考组件的上.下.左.右等位置,这些能够直接通过各个组件提供的属性完毕. 以下介绍一下各个方法的基本使用 No. 属性名 ...

  2. 从头学Android系列

    从头学Android系列 http://blog.csdn.net/worker90/article/category/888358

  3. 从头学Android之Android布局管理:LinerLayout线性布局

    LinerLayout线性布局: 这种布局方式是指在这个里面的控件元素显线性,我们可以通过setOrientation(int orientation)来指定线性布局的显示方式,其值有:HORIZON ...

  4. 从零開始学android&lt;使用嵌套布局实现计算器界面.十七.&gt;

    所谓的嵌套布局就是在一个文件里嵌套多个布局文件 <span style="font-size:18px;"> <LinearLayout android:layo ...

  5. 23、从头学Android之ContentProvider .

    http://blog.csdn.net/jiahui524/article/details/7016430 应用场景: 在Android官方指出的Android的数据存储方式总共有五种,分别是:Sh ...

  6. Android之RelativeLayout相对布局

    1.相关术语解释 1.基本属性 gravity :设置容器内组件的对齐方式 ignoreGravity : 设置该属性为true的组件,将不受gravity属性的影响 2.根据父容器定位 layout ...

  7. 一步一步学android之布局管理器——RelativeLayout

    今天开始学习RelativeLayout(相对布局),相对布局在平时布局的时候用的较多,因为Android适配方面的原因.相对布局可以控制组件摆放的位置(放在任一组件的上下左右等位置),下面来看看类的 ...

  8. 第13章、布局Layouts之RelativeLayout相对布局(从零開始学Android)

    RelativeLayout相对布局 RelativeLayout是一种相对布局,控件的位置是依照相对位置来计算的,后一个控件在什么位置依赖于前一个控件的基本位置,是布局最经常使用,也是最灵活的一种布 ...

  9. Android开发重点难点1:RelativeLayout(相对布局)详解

    前言 啦啦啦~博主又推出了一个新的系列啦~ 之前的Android开发系列主要以完成实验的过程为主,经常会综合许多知识来写,所以难免会有知识点的交杂,给人一种混乱的感觉. 所以博主推出“重点难点”系列, ...

随机推荐

  1. freemarker中使用<@spring.*>标签实现国际化

    freemarker实现国际化使用自定义指令<@spring>实现,通过@符号可以看出是自定义的指令,在哪里定义的呢? 路径如下:org/springframework/spring-we ...

  2. SpringBoot(4) SpringBoot热部署

    热部署,就是在应用正在运行的时候升级软件,却不需要重新启动应用. 使用springboot结合dev-tool工具,快速加载启动应用 官方地址:https://docs.spring.io/sprin ...

  3. springboot aop 自定义注解方式实现完善日志记录(完整源码)

    版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 一:功能简介 本文主要记录如何使用aop切面的方式来实现日志记录功能. 主要记录的信息有: 操作人,方法名,参数,运行时间,操作类型 ...

  4. [转]window7下利用DockerToolbox安装Docker

    本文转自:https://blog.csdn.net/qq2712193/article/details/54576313 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blo ...

  5. 菜鸟入门【ASP.NET Core】8:Middleware管道介绍、自己动手构建RequestDelegate管道

    中间件:是汇集到以处理请求和响应的一个应用程序管道的软件. 每个组件: 可以选择是否要将请求传递到管道中的下一个组件. 之前和之后调用管道中的下一个组件,可以执行工作. 使用请求委托来生成请求管道.  ...

  6. 【Java深入研究】6、CGLib动态代理机制详解

    一.首先说一下JDK中的动态代理: JDK中的动态代理是通过反射类Proxy以及InvocationHandler回调接口实现的 但是,JDK中所要进行动态代理的类必须要实现一个接口,也就是说只能对该 ...

  7. 服务器端事件发送SSE

    背景 近期有这么一个需求: 手机端需要展示一个比较大的pdf 基于手机端网络/流量/体验等考虑,希望不通过pdf下载然后展示 而是把pdf转成一张张的图片,然后再在手机上展示. 分析 pdf转图片,肯 ...

  8. Python3 系列之 编程规范篇

    编码规范 编码 如无特殊情况, 文件一律使用 UTF-8 编码 如无特殊情况, 文件头部必须加入 #--coding:utf-8-- 标识 缩进 统一使用 4 个空格进行缩进 引号 自然语言 使用双引 ...

  9. 解决VM提示:VMware Workstation cannot connect to the virtual machine. Make sure you have rights to run the program, access all directories the program uses, and access all directories for temporary files.

    问题: 在开启虚拟机的时候报: VMware Workstation cannot connect to the virtual machine. Make sure you have rights ...

  10. spark_wordcount

    spark是基于scala写的,虽然spark有java API,或者python API,但是scala算是正统吧. 而且scala的语法书写起来十分的爽,不想java那样笨重,python不太了解 ...