在谈这个之前先啰嗦几个概念。

基线:书写英语单词时为了规范书写会设有四条线,从上至下第三条就是基线。基线对齐主要是为了两个控件中显示的英文单词的基线对齐,如下所示:

  

Start:在看API的时候经常会有Start对齐,End对齐,Start对齐主要是为了能够在不同的textDirection(文本排列方向)的时候更好的对齐的一种方式,在textDirection为LTR(从左到右)时Start对齐就等于左对齐,当textDirection为RTL(从右到左)时Start对齐就等于右对齐。End同理。

文本对齐

  通过gravity来实现view的文本对齐方式.先看下官方解释。

  android:gravity:Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view.

Must be one or more (separated by '|') of the following constant values.

  意思是说,当文本比view小的时候指定如何通过view的x、y轴线去对齐。这个属性的值必须是下面给出的一个或多个,如果是多个则用'|'隔开。

  可以用的属性有:topbottomleftrightcenter_verticalfill_verticalcenter_horizontalfill_horizontalcenterfillclip_verticalclip_horizontalstartend

  这些属性中就谈两类,其他的类似,一个是上下左右这种基本类型的,还有一种是组合的,比如左下角,这是为:left|bottom。

  左对齐:

  

 <TextView
android:layout_width="100dip"
android:layout_height="60dip"
android:layout_marginTop="10dip"
android:background="#ffff33"
android:gravity="left"
android:text="left"
/>

  左下角:

  <TextView
android:layout_width="100dip"
android:layout_height="60dip"
android:layout_marginTop="10dip"
android:background="#ffff33"
android:gravity="left|bottom"
android:text="leftbottom"
/>

  效果图如下所示:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJkAAACmCAIAAABGErqVAAAFMklEQVR4nO3dv2siWxwF8PxJHrBQ2CqQIsIWEVIobCGDRZAUQVIsYZsgWwTZIqQS2SJgikBeIWghmCZgigdJEdAiYIoUFhZTWNxiinlF7suMMpof+3hf/N5zOMXNcOcm3k+cMdNkw8wMq6MbhtGSjTAIWR3dCBktoaWe0FJPaKkn77QE++6KhZa0ZGnpQMXyXstmA+PHN17G3T2OfqDfE99NWq4KctvoX696DZNnII1+D74PY2Bm4ntKy+S8bdk6R/XAjuu/UPspvqe0TM6ipe+j38PgBsYgDDEc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rdf+kstV8yPr99swCvbsZkBqcWrOi3DuOVwZC1bF7Yvx99jaQyQwvjJLhIGc8df9j3RcsX8+Pqtc1T2Fr8XLRcSWfpTIJXwt+a73peP9v3k+3OL2OuhWWq5Yj4tX/OZzz5eOWIbP9lLX9zy6hJeKbKs7MMYhAFqxyh+s8cr+//OD1A9xNGPhHPj42Xzafmaz1iaGaoHyGaQzaBYsPsVt/SnyH0F0vZz7OAWm1tAGvnd6J5nTLTI0Xf7Jls4Nz5eNp+Wr/mD57FBdANbOmHFl6sXCZaPV39T+YqFz9ZpydLSgYqF/5tNT2ipJ7TUE1rqCS31hJZ6Qks9oaWe0FJPaKkntNQTWuoJLfWElnpCSz2hpZ7QUk9oqSe01BNa6gkt9YSWekJLPaGlntBST2ipJ7TUE1rqCS315B+n2CAGsonz0wAAAABJRU5ErkJggg==" alt="" />

LinearLayout对齐

  gravity:Specifies how an object should position its content, on both the X and Y axes, within its own bounds.

Must be one or more (separated by '|') of the following constant values.

    意思是,规定了一个对象以什么样的方式根据x、y轴去摆放自己的内容。这个属性的值必须是下面给出的一个或多个,如果是多个则用'|'隔开。

    可以用的属性有:topbottomleftrightcenter_verticalfill_verticalcenter_horizontalfill_horizontalcenterfillclip_verticalclip_horizontalstartend。

    同样,这些属性中就谈两类,其他的类似,一个是上下左右这种基本类型的,还有一种是组合的,比如左上角,这是为:left|bottom。

  居右对齐:

  

 <LinearLayout
android:layout_width="match_parent"
android:background="#0000ff"
android:layout_height="0dip"
android:gravity="right"
android:layout_weight="1" > <Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="right"
/> </LinearLayout>

  居左下角对齐:

 <LinearLayout
android:layout_width="match_parent"
android:background="#ffff33"
android:layout_height="0dip"
android:layout_marginTop="10dip"
android:gravity="left|bottom"
android:layout_weight="1" > <Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="left_bottom"
/>
</LinearLayout>

  效果图如下:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAA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ClLurZssGt6sCseCZWXFrE+LABIGVP14tTA4uTAVix8V1rK+rAAIGVM1f75Mf/86O5mtLqyjPVhAUDKku+aMBVanNrbij2oKmd9WACQMqbqsGcm7JnZ34njrgkAnMZUHfHORbxzB7jDEQDHMVXjfuAAZEDVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApEHVAKRB1QCkQdUApPlw1b9hwoSJsxOqxoSJtAlVY8JE2oSqMWEibULVmDCRNqFqTJhIm1A1JkykTagaEybSJlSNCRNpE6rGhIm06WNVZwAAR6FqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqANKgagDSoGoA0qBqAN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ezpdvT3D/X2jgwPjgwNTQ/0zw8654b6pgeSqVTZNk6VZbmxqMDY1GJUNRmWjUdVoVDa0NdUbFHU6eW2rvFYrq9HIatSNj1saH7c0PmppeNTS8Ejd+FjTWKOV1bbKn+jkT/TyOoOizqCoM8if6GS1rY01mobHmsbHGlmNVl6rVdTqlHWG5ga6bYtWYdHKLdqjLUAzn1DLUfXlqjqwMOV/Pumbn1iYGZ0dHx4fdg31Owf6evscPd1dXXZ7p81m6+josFqtFrOlw2KxWS2dHZZum7Wv0zrQ3THs6Bjv6xjpMQ/ajU6rztGu7m5rtutUVm2TWS03t8iPj9jy9ubGNmW9XlGrlT3WHCfdVPN/lbX/2fzkv1rq/qmuf6RpfNwqq9XJnxgUdW1N9UZlQzvdc7Pc3CK3qBUWTdNJ1XZDs02ntGoVZo2s/ajqBoOqwaBsaFfLO3TN3UZtn8XgtBqcVkO/1dBvParaYdL0tKvtBpVFq2hvadA3PdE3PdEr6/TKOr2qvq25wdjSaNLILNrjpI8xP9BqmamlsV3VQFfd3ixrb1GY1E12g6bX2jbYbZ0Y6J4e6p0d7Z8fdz2fGno2OfR0fHB21DU93D/h6h1zdg07bIOdZlenxdVldXXbXD32od7uYadjdMA5PuiaHBqYHu6fHel/OuKccXWPO6xDdmO/Setoa+nUqTrUTSaVzEQfqJtlpmb690tDW1OdXvFEJ69tTa66IalqWU2rvFanqNMr6gz05lU2GulfB7JabeNjbeNjjaxGI6vRyGtaFU/0yrq25oZ2tcykkdFnNB+oWi0zq2X/DzLxQE7vuVMLAAAAAElFTkSuQmCC" alt="" />

RelativeLayout对象

  RelativeLayout主要用到相对位置的对齐,主要属性有以下几种

  

layout_above

该布局文件的底部设置到指定ID的对象的上方
layout_below

layout_alignBaseline

该布局文件的基线与指定ID的对象的基线对齐

layout_alignBottom

将该布局文件的底部域指定的ID的对象的底部对齐

layout_alignLeft

layout_alignRight
layout_alignTop

layout_alignStart

该布局文件的开始(左边)与指定ID对象的开始(左边)位置对齐

layout_alignEnd

该布局文件的结束(右边)与指定ID对象的结束(右边)位置对齐

layout_toLeftOf

该布局文件的右边放到指定ID对象的左边
类似:layout_toStartOf

layout_toRightOf

该布局文件的左边放到指定ID对象的右边

layout_centerHorizontal

如果设置为true,则将该布局文件中的自对象设置为水平居中
layout_centerInParent
layout_centerVertical

layout_alignParentLeft

如果设置为true,则将该布局文件的左边与其父对象的左边对齐
layout_alignParentRight
layout_alignParentStart
layout_alignParentTop

layout_alignParentEnd

layout_alignParentBottom

  拿出两个例子来简单说明下,一个是将一个button放到另一个button右边,另外一个是将一个button放到另一个button的右下角

  右边:

  

  <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > <Button
android:id="@+id/btnStand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标准物1" /> <Button
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/btnStand"
android:text="right->标准物1" />
</RelativeLayout>

  右下角:

 <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > <Button
android:id="@+id/btnStand2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标准物2" /> <Button
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_below="@id/btnStand2"
android:layout_toRightOf="@id/btnStand2"
android:text="right_bottom->标准物2" />
</RelativeLayout>

  效果图如下所示:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUEAAAEBCAIAAABpNIAKAAAb90lEQVR4nO2dP0jd3v//X4NDhg4ZHDI49EIHAw4GOhhwsBcceqGDgQ4NOJRLBwkOcukgly7l0kEuHd5cHMqlgxAHIQ5CHIR0EdJBiEMhDheyvIcO36HDb3D4DP6Gl+/TmHu83nuNTWKfD16Uxuu9ueacR87/E9IAAJVlZWWFiv4OAIDpWVlZoeBbgEAgKhorKyv0EwBQWVZWVugX83///YtAIMoWw27+5+zKygpd/r9LBAJR0VhZWaHLy8ur/11d/e/q8vIyGSTxj/gviWSQXN7CX3Ud7nmtwJ+HbeX/r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5ZP61l+D10Npw7t5XliM4iZ8ORbJf5I/YOPXffHfHsUjj89wCH5fxJN6oSRacJkAOH5RQuTAmj6DQBcuCwnMKFKWEUnSZADhyWU7gwJYyi0wTIgcNyChemhFF0mgA5cFhO4cKUMIpOEyAHDssJT8PgJECICE/DotMEyIHDt3J5efkL/Pr169evy8vLolMD3AocBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDawGEAqg0cBqDarKys/H9Y2vf+YeuMEAAAAABJRU5ErkJggg==" alt="" />

后记:

  这次谈的内容比较粗,仅作抛砖引玉用。

原文连接:http://www.cnblogs.com/luoaz/p/3719767.html

Demo下载地址:https://github.com/xiaoai-opensource/alignDemo

粗谈Android中的对齐的更多相关文章

  1. 浅谈android中只使用一个TextView实现高仿京东,淘宝各种倒计时

    今天给大家带来的是只使用一个TextView实现一个高仿京东.淘宝.唯品会等各种电商APP的活动倒计时.近期公司一直加班也没来得及时间去整理,今天难得歇息想把这个分享给大家.只求共同学习,以及自己兴许 ...

  2. 浅谈Android中Serializable和Parcelable使用区别

    版权声明:本文出自汪磊的博客,转载请务必注明出处. 一.概述 Android开发的时候,我们时长遇到传递对象的需求,但是我们无法将对象的引用传给Activity或者Fragment,我们需要将这些对象 ...

  3. 浅谈android中的目录结构

    之前在android游戏开发中就遇到本地数据存储的问题:一般情形之下就将动态数据写入SD中存储,在没有SD卡的手机上就需另作处理了;再有在开发android应用的过程中,总要去调试APP,安装时又想去 ...

  4. 浅谈Android中拍照、从相册选择图片并截图相关知识点

    前言 我们在Android开发中经常会需要使用相机或者从相册中选取图片的情况,今天就把这里面相关的知识点总结下,方便以后开发的时候使用. 1.相机拍照并可自定义截图功能 我们先来看如何使用Intent ...

  5. 浅谈Android中的startActivityForResult和setResult方法

    引言 我们知道,如果想打开一个新的Activity我们可以使用startActivity方法.今天我们介绍的startActivityForResult不仅可以打开全新的Activity,而且当新的A ...

  6. 浅谈Android中layout_weight

    引言 在开发android过程中,我们经常需要对界面进行按比例进行布局,我们一般都会使用layout_属性来进行设置.今天这篇文章我们就来简单介绍下layout_weight的使用和布局原理.随着做项 ...

  7. 浅谈Android中Activity的生命周期

    引言 我想对于Android开发人员来说,Activity是再熟悉不过了,今天我们就来探讨下Activity的生命周期.熟悉的掌握Activity对于开发健壮的Android应用程序来说至关重要.下面 ...

  8. 粗谈Android未来前景

    Andriod作为智能手机机兴起的操作系统,有着非同寻常的地位.而相对于他的竞争对手ios,两大系统各有自身的优缺点,有太多的不同点,但相比较用户体验来说ios略胜一筹. Android系统极具开发性 ...

  9. 浅谈Android中的事件分发机制

    View事件分发机制的本质就是就是MotionEvent事件的分发过程,即MotionEvent产生后是怎样在View之间传递及处理的. 首先介绍一下什么是MotionEvent.所谓MotionEv ...

随机推荐

  1. java_ExecutorService, CompletionService - 有返回值并行工作方式

    package com.demo.test3; import java.util.ArrayList; import java.util.List; import java.util.Random; ...

  2. 修改范围PHP_INI_SYSTEM与PHP_INI_ALL的区别

    PHP_INI_USER 可在用户脚本(例如 ini_set() )或 Windows 注册表(自 PHP 5.3 起)以及 .user.ini 中设定 PHP_INI_PERDIR 可在 php.i ...

  3. Spring 的微内核与FactoryBean扩展机制--转载

    作者:江南白衣 原文地址: http://www.blogjava.net/calvin/archive/2005/08/30/11099.html http://www.blogjava.net/c ...

  4. Virtualbox - 共享文件夹

    在虚拟机中添加共享文件夹——比如主机中的/home/user/download,我想把download文件夹共享给虚拟机用. 步骤:1.在虚拟机中找个挂载的目录,比如 /mnt/d,没有就新建一个目录 ...

  5. Content-Type一览

    文件扩展名 Content-Type(Mime-Type) 文件扩展名 Content-Type(Mime-Type) .*( 二进制流,不知道下载文件类型) application/octet-st ...

  6. spring+hibernate+struts整合(2)

    spring和struts2的整合 1:配置Web.xml文件 <filter> <filter-name>struts2</filter-name> <fi ...

  7. 根据url获取网页内容

    PrintWriter out = null; out = response.getWriter(); try{ URL getUrl = new URL("http://www.kuaid ...

  8. Eclipse NDK 配置,无需安装Cygwin

    Eclipse NDK 配置,不用安装Cygwin 文章转自http://www.cnblogs.com/chenjiajin/archive/2012/04/12/2444188.html 一.关于 ...

  9. Visual Studio Team Foundation Server 2015(TFS 秘钥、序列号)

    Visual Studio Team Foundation Server 2015 序列号:PTBNK-HVGCM-HB2GW-MXWMH-T3BJQ

  10. js验证 button 提交

    <form class="form-horizontal" role="form" action="member_add" metho ...