Android Guides | Samples

Android.Widget.RelativeLayout Class

A Layout where the positions of the children can be described in relation to each other or to the parent.

See Also: RelativeLayout

Syntax

[Android.Runtime.Register("android/widget/RelativeLayout", DoNotGenerateAcw=true)]
public class RelativeLayout : ViewGroup

Remarks

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 ViewGroup+LayoutParams.WrapContent and a child set to 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 NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html values. (See NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html#makeMeasureSpec(int, int) 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 NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html#UNSPECIFIED was placed in a RelativeLayout, this would silently work anyway as RelativeLayout would pass a very large NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html#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

See the Relative Layout guide.

Also see NoType:android/widget/RelativeLayout$LayoutParams;Href=../../../reference/android/widget/RelativeLayout.LayoutParams.html for layout attributes

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Widget.RelativeLayout are listed below.

See Also: ViewGroup

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
GravityGravityFlags. Describes how the child views are positioned.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

SetGravity(GravityFlags)
Describes how the child views are positioned.
SetHorizontalGravity(GravityFlags)
SetIgnoreGravity(Int32)
Defines which View is ignored when the gravity is applied.
SetVerticalGravity(GravityFlags)

Protected Methods

override
OnLayout(Boolean, Int32, Int32, Int32, Int32)
Called from layout when this view should assign a size and position to each of its children.