android:gravity 针对本view 的位置。

android:layout_gravity 本view相对于父布局view的位置。

android:layout_alignParentRight 使当前控件与父布局右端对齐。

android:layout_marginLeft="10dip" 使当前控件左边缘离上层布局的距离

android:layout_alignParentLeft   使当前控件贴紧父元素的左边缘

android:layout_toLeftOf="@id/ok" 使当前控件置于id 为ok的控件的左端

android:layout_alignTop="@id/ok" 使当前控件置于id为ok的控件上端 对齐

android:layout_centerInParent="true" 居中在父对象

================================================================

=========================================================

=========================================================

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="230dip"
android:layout_height="wrap_content"
android:background="@drawable/gray"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center"
android:orientation="vertical" > <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dip"
android:paddingTop="10dip" > <ImageView
android:id="@+id/dialog_title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="10dip"
android:layout_toRightOf="@id/dialog_title_image"
android:text="Title"
android:textColor="#000000"
android:textSize="30sp" />
</RelativeLayout> <TextView
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="1dip"
android:background="@color/blue" /> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dip"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:paddingTop="10dip"
android:text="This is a custom dialog This is a custom dialogThis is a custom dialogThis is a custom dialogThis is a custom dialogThis is a custom dialogThis is a custom dialog"
android:textColor="#000000" /> <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom|center_horizontal"
android:paddingBottom="10dip"
android:paddingTop="10dip" > <Button
android:id="@+id/dialog_button_cancel"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="确定" /> <Button
android:id="@+id/dialog_button_ok"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="35dip"
android:layout_toRightOf="@id/dialog_button_cancel"
android:text="取消" />
</RelativeLayout> </LinearLayout>

http://blog.csdn.net/yuejingjiahong/article/details/6672707

android 入门-布局的更多相关文章

  1. 【腾讯Bugly干货分享】Android动态布局入门及NinePatchChunk解密

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57c7ff5d53bbcffd68c64411 作者:黄进——QQ音乐团队 摆脱 ...

  2. 【详细】Android入门到放弃篇-YES OR NO-》各种UI组件,布局管理器,单元Activity

    问:达叔,你放弃了吗? 答:不,放弃是不可能的,丢了Android,你会心疼吗?如果别人把你丢掉,你是痛苦呢?还是痛苦呢?~ 引导语 有人说,爱上一个人是痛苦的,有人说,喜欢一个人是幸福的. 人与人之 ...

  3. Android入门(十):界面的布局方式及其实际应用

    关于Android界面布局,网上已经有了很多非常不错的学习资料,在这里我也不班门弄斧了,推荐两篇我认为写的不错的教程,然后再重点讲一下几种布局方式的实际应用. 教程链接:①http://www.cnb ...

  4. 小猪的Android入门之路 Day 4 - part 1

    小猪的Android入门之路 Day 4 - part 1 Android事件处理机制之--基于监听的事件处理机制 本节引言: 在開始本个章节前,我们先回想下,如今我们已经知道了android的一些相 ...

  5. Android入门第一课之Java基础

    通知:由于本周六场地申请没通过,所以本周的培训临时取消. 今天给大家带来的是Android入门的第一课,由于教室申请的不确定性,因此,每次培训的内容都会在博客先提前释放出来.首先Android的APP ...

  6. 前端之Android入门(3):MVC模式(上)

    很多Android的入门书籍,在前面介绍完布局后就会逐个介绍组件,然后开始编写组件使用的例子.每每到此时小伙伴们都可能会有些疑问:是否应该先啃完一本<Java编程思想>学点 Java 知识 ...

  7. android入门小结一

    一 Android入门基础:从这里开始 gradle介绍: Android Studio使用Gradle 编译运行Android工程. 工程的每个模块以及整个工程都有一个build.gradle文件. ...

  8. Android精通教程-第一节Android入门简介

    前言 大家好,给大家带来Android精通教程-第一节Android入门简介的概述,希望你们喜欢 每日一句 If life were predictable it would cease to be ...

  9. UniMelb Comp30022 IT Project (Capstone) - 1.Android入门

    1. Android入门 Android系统架构 Android系统:四层架构.五块区域 1. Linux内核层 Linux Kernel:为Android设备的硬件提供了底层驱动 2. 系统运行库层 ...

随机推荐

  1. python traceback 变量值

    import sys import traceback import cgitb def handleException(excType, excValue, trace): print 'error ...

  2. oracle数据库备份

    --数据库备份--导出 exp userid=shoppingsys/shoppingsys@orcl file=/home/oracle/shoppingsys.dmp log=/home/orac ...

  3. Starting MySQL.The server quit without updating PID file (xxxx.pid).[FAILED]

    mysql无法正常启动,查看日志报如下异常 --07T01::.929615Z [ERROR] Fatal error: Please read "Security" sectio ...

  4. zju3547

    题意:给出n(1<=n<=10^8),求小于n的,求所有与n互质的数字的四次幂的加和是多少. 分析:容斥原理 首先要知道四次幂求和公式,1^4+2^4+...+n^4=n*(n+1)*(2 ...

  5. ABAP 自建透明表维护

    *&---------------------------------------------------------------------* *& Report  ZMMR011 ...

  6. Match:Censored!(AC自动机+DP+高精度)(POJ 1625)

     Censored! 题目大意:给定一些字符,将这些字符组成一个固定长度的字符串,但是字符串不能包含一些禁词,问你有多少种组合方式. 这是一道好题,既然出现了“一些”禁词,那么这题肯定和AC自动机有点 ...

  7. java classpath批量设置shell脚本

    java classpath批量设置shell脚本   注意:linux bash jar文件之间的分隔符是':'    export JAR_HOME=path to directory which ...

  8. C# 总复习

    1.循环语句 四要素:初始条件.循环条件.循环体.状态改变 循环的最后一句:循环条件不再满足 2. ++     --int a = 5; //在赋值语句中,后++需要,先进性赋值,然后进行+1运算 ...

  9. vs2010:fatal error LNK1123: 转换到 COFF 期间失败

    解决方法: 项目\属性\配置属性\清单工具\输入和输出\嵌入清单:原来是“是”,改成“否”.

  10. UVA 10815 Andy's First Dictionary ---set

    题目链接 题意:输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单词不区分大小写. 刘汝佳算法竞赛入门经典(第二版)P112 #include <iostream> ...