完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/RelativeLayout.html
RelativeLayout
public class RelativeLayout
extends ViewGroup
java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | android.widget.RelativeLayout |
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. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT
and a child set to ALIGN_PARENT_BOTTOM
.
注意,你不能在的RelativeLayout大小和其子项位置之间有一个循环依赖关系。例如,你不能有一个设置了WRAP_CONTENT
的RelativeLayout,并且将一个子项设置为ALIGN_PARENT_BOTTOM
。
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. (See MeasureSpec.makeMeasureSpec
for more details.) 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.
注意:在17或更低的平台版本中,相对布局受到一个测量bug的影响,它可能导致子视图以不正确的MeasureSpec
来测量。(参考MeasureSpec.makeMeasureSpec
获取更详细的信息)。当把一个RelativeLayout容器放置到一个滚动容器(如ScrollView或HorizontalScrollView)中时,这个bug将被触发。如果放置在RalativeLayout中的自定义视图使用UNSPECIFIED
的MeasureSpec的模式而没有设置适当的测量,它也能工作,但是RelativeLayout会传入一个非常大的AT_MOST
MeasureSpec。
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
这种行为是为了应用程序在manifest的uses-sdk
标签中设置android:targetSdkVersion="17"
或更老版本中的兼容。18或更新的版本的应用程序将会得到正确的行为
See the Relative Layout guide.
请参考Relative Layout指南。
Also see RelativeLayout.LayoutParams
for layout attributes
参考RelativeLayout.LayoutParams
了解布局属性。
摘要
嵌套类 | |
---|---|
class | RelativeLayout.LayoutParams Per-child layout information associated with RelativeLayout. |
XML属性 | |
---|---|
android:gravity | 在一个对象自身的边界内,它如何在x轴和y坐标轴上放置其内容。 |
android:ignoreGravity | 不受重力值影响的视图。 |