Android - RelativeLayout布局
2014-12-10 08:59
67 查看
RelativeLayout布局
本文地址:http://blog.csdn.net/caroline_wendyRelativeLayout是一种相对布局方式,是根据属性进行对齐;A Layout where the positions of the children can be described in relation to each other or to the parent.在布局中,子控件的位置根据相互之间的关系进行描述。Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. 子控件之间不能存在循环依赖。
Note: In platform version 17 and lower, RelativeLayout was affected by a measurement bug that could cause child views to be measured with incorrect MeasureSpec values. This was triggered when a RelativeLayout container was placed in a scrolling container, such as a ScrollView or HorizontalScrollView. If a custom view not equipped to properly measure with the MeasureSpec mode UNSPECIFIED was placed in a RelativeLayout, this would silently work anyway as RelativeLayout would pass a very large AT_MOST MeasureSpec instead.This behavior has been preserved for apps that set android:targetSdkVersion="17" or older in their manifest's uses-sdk tag for compatibility. Apps targeting SDK version 18 or newer will receive the correct behavior
属性名称 | 描述 |
android:layout_below | 摆放在指定组件的下边 |
android:layout_toLeftOf | 摆放在指定组件的左边 |
android:layout_toRightOf | 摆放在指定组件的右边 |
android:layout_alignTop | 以指定组件作为参考进行上对齐 |
android:layout_algnBottom | 以指定组件作为参照进行下对齐 |
android:layout_alignLeft | 以指定组件作为参考进行左对齐 |
android:layout_alignRight | 以指定组件 |
android:layout_toStartOf="@+id/buttonTweet” //表是在某个控件的前对齐,如果不知道,就图形界面拖动
<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" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".StatusActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_tweet" android:id="@+id/buttonTweet" android:layout_alignParentEnd="true"/> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textMultiLine" android:ems="10" android:id="@+id/editText" android:layout_alignParentBottom="true" android:layout_alignParentStart="true" android:hint="@string/hint_status" android:layout_toStartOf="@+id/buttonTweet"/> <TextView android:id="@+id/textCount" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignEnd="@id/buttonTweet" android:layout_below="@id/buttonTweet" android:text="140" android:textAppearance="?android:textAppearanceSmall"/> </RelativeLayout>
相关文章推荐
- 体验Android
- Android源码各个击破之-系统属性
- Study on Android【一】--概述
- 机器人Android在呼唤!
- Google Android IDE-eclipse plugin 预览
- 为什么是java,google的android策略
- Android Developer Challenge
- Google Calling: Inside Android, the gPhone SDK
- Android程序开发初级教程(三)
- Android程序开发初级教程(二)
- 什么是google的Android操作系统?
- Google手机操作系统Android应用开发入门
- Android程序开发初级教程(一)
- Android 入门开发指南之一 -- Android简介
- Android 原代码下载路径
- 体验Android:个人所得税计算器 含源码
- Android判断字符串中是否含字母、中文或数字
- 体验Android
- Google 1000万美元重奖Android开发者
- Android安装以及Eclipse插件(Google Android) ,在Android 中google搜索 博客园界面