android:layout_alignParentLeft="true" 位于父容器左上角 android:layout_alignParentBottom, android:layout_alignParentTop, android:layout_alignParentRight  只能在父控件为RelativeLayout时才起作用,而对于像LinearLayout这样的布局不起作用

android:layout_centerInParent="true" 位于布局容器的中央位置;

layout_centerHorizontal位于布局容器水平居中位置;

layout_centerVertical位于布局容器垂直居中位置

被参照控件:控件与控件之间位置

android:layout_below="@id/aclock" 位于aclock组件下方

android:layout_toLeftOf="@id/dclock"位于dclock组件左则

控件与控件之间对齐方式  

android:layout_alignLeft="@id/aclock"与aclock组件左边界对齐;

android:layout_alignTop="@id/aclock"与aclock组件上边界对齐

效果:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AndroidRelativeLayoutActivity" >

<AnalogClock
android:id="@+id/aclock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
</AnalogClock>

<!--
android:layout_below="@id/aclock" 位于模拟时钟下面。如果没有设置属性layout_alignLeft和layout_marginLeft ,
该数字时钟会顶到左屏幕边显示;alignLeft="@id/aclock" 和属性layout_below 配合使用,使得该数字时钟和上面的模拟时钟的左边距对齐,
如果没有设置marginLeft 属性的话和上面的两个属性配合使用,使得数字时钟距模拟时钟的左边距40个像素

-->

<DigitalClock
android:id="@+id/dclock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/aclock"
android:layout_below="@id/aclock"
android:layout_marginLeft="40px" >
</DigitalClock>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/aclock"
android:layout_toLeftOf="@id/dclock"
android:text="当前时间" >
</TextView>

</RelativeLayout>

android 布局居中的更多相关文章

  1. Android布局居中的几种做法

    Android的布局文件中,如果想让一个组件(布局或View)居中显示在另一个布局(组件)中,可以由这么几种做法: android:layout_gravity android:gravity and ...

  2. android布局居中

    添加android:gravity="center" 或者android:layout_gravity="center"属性.android:gravity用于 ...

  3. Android 布局之FrameLayout

    Android 布局之FrameLayout 1 FrameLayout简介 对于FrameLayout,官方介绍是:FrameLayout is designed to block out an a ...

  4. android布局常用属性记录

    android布局常用属性记录   http://blog.csdn.net/xn4545945/article/details/7717086这里有一部分别人总结的其余的: align:对齐 par ...

  5. Android 布局详解

    Android 布局详解 1.重用布局 当一个布局文件被多处使用时,最好<include>标签来重用布局. 例如:workspace_screen.xml的布局文件,在另一个布局文件中被重 ...

  6. Android布局及属性归总(查询用)

    常见布局 LinearLayout    线性布局        子元素任意,组织成一个单一的水平或垂直行,默认为水平方向TableLayout    表格布局        子元素为<Tabl ...

  7. Android布局管理详解(1)—— LinearLayout 线性布局

    Android的布局方式共有6种,分别是LinearLayout(线性布局).TableLayout(表格布局).FrameLayout(帧布局).RelativeLayout(相对布局).GridL ...

  8. ZT Android布局】在程序中设置android:gravity 和 android:layout_Gravity属性

    Android布局]在程序中设置android:gravity 和 android:layout_Gravity属性 分类: [Android基础] 2011-04-19 16:06 54739人阅读 ...

  9. Android布局需要知道的基础知识

    eclipse配置环境变量: 1.在 eclipse 中的 Window --> preferences  --> Android(安装了ADT的前提下才能看到Android) --> ...

随机推荐

  1. HDU 1573 X问题 (中国剩余定理)

    题目链接 题意 : 中文题不详述. 思路 : 中国剩余定理.求中国剩余定理中解的个数.看这里看这里 #include <stdio.h> #include <iostream> ...

  2. Linux 2.4.x内核软中断机制

    http://www.ibm.com/developerworks/cn/linux/kernel/interrupt/ 软中断概况 软中断是利用硬件中断的概念,用软件方式进行模拟,实现宏观上的异步执 ...

  3. PCB走线角度选择 — PCB Layout 跳坑指南

    现在但凡打开SoC原厂的PCB Layout Guide,都会提及到高速信号的走线的拐角角度问题,都会说高速信号不要以直角走线,要以45度角走线,并且会说走圆弧会比45度拐角更好.狮屎是不是这样?PC ...

  4. AutoCAD图形打印出图片 C#

    这几天搞cad二次开发,用的是C#语言,目前在网上找到的资料比较少.弄了两天,才做出怎样实现打印出图片.首先得在AutoCAD软件界面下,设置打印机的页面设置和打印机设备名称一样(以防打印不出来).即 ...

  5. 《Linux/Unix系统编程手册》读书笔记2

    <Linux/Unix系统编程手册>读书笔记 目录 第5章: 主要介绍了文件I/O更深入的一些内容. 原子操作,将一个系统调用所要完成的所有动作作为一个不可中断的操作,一次性执行:这样可以 ...

  6. (1)WinForm和WebForm

    如上所述,WinForm程序通常分为四层,而WebForm程序通常分为三层.   举例说明,winForm程序: IEnumerable<BatchUpdateResult<string, ...

  7. .net MVC APi调用

    常用的调用方法为Get/Post Get方法: 服务器 public string Get(int id) { return "value"; } 这个直接在网页就可以测试,用 h ...

  8. Java泛型中的extends和super关键字

    理解List<? extends T> list, T key, Comparator<? super T> c 这些一般用在方法形参类型上,用于接受泛型对象. 1.List& ...

  9. 小娱乐一下,fileInfo中的Name ,FullName的用法小BUG

    var filePath = new FileInfo(@"c:\text(sdf\123).txt"); Console.WriteLine(filePath.Name); Co ...

  10. Servlet错误一览

    错误:HTTP Status 405 - HTTP method POST is not supported by this URL 原因:没有提供doPost方法 错误:控制器跳转到空白界面 原因: ...