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. github 多个项目共用同一个key的方法

    后面的项目不用添加ssh keys, 直接在项目下设置合作者(Collaborators), 搜索出去加进去即可免密码传代码.

  2. Linux--网络通信命令(给其它用户发送广播消息)

    1.命令名称:write 执行权限:所有用户  功能描述:向另外一个用户发送信息,以CTRL+D作为结束 语法:write <用户名>root向luxh用户发送信息[root@localh ...

  3. 【GoLang】panic defer recover 深入理解

    唉,只能说C程序员可以接受go的错误设计,相比java来说这个设计真的很差劲! 我认为知乎上说的比较中肯的: 1. The key lesson, however, is that errors ar ...

  4. Java总结(二):继承——Inheritance

    关于继承: 1.为了重用代码——引入继承. 2.父类的某些方法反正要被重写,在父类里实现在也无用——引入抽象类. 3.把抽象类里的抽象方法抽出来——引入接口.

  5. Closest Binary Search Tree Value I & II

    Closest Binary Search Tree Value Given a non-empty binary search tree and a target value, find the v ...

  6. join

    一句话 join(param) 是把  array 连城一个字符串,中间用 param隔开

  7. sharepoint更新左侧列表的名字

    SPWeb myweb = SPContext.Current.Web;            SPList myList = myweb.Lists["nihao"];      ...

  8. 【leetcode】Validate Binary Search Tree

    Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST) ...

  9. [ 转] [Android]多式样ProgressBar

    多式样ProgressBar 普通圆形ProgressBar 该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中. 一般只要在XML布局中定义就可以了. < ...

  10. Spring mvc中@RequestMapping 6个基本用法小结(转载)

    小结下spring mvc中的@RequestMapping的用法. 1)最基本的,方法级别上应用,例如: @RequestMapping(value="/departments" ...