Build 1.0_r1(from source)

android.widget
Class RelativeLayout

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.RelativeLayout
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewManager, ViewParent
Direct Known Subclasses:
DialerFilter, TwoLineListItem

public class RelativeLayout
extends ViewGroup

A Layout where the positions of the children can be described in relation to each other or to the parent. For the sake of efficiency, the relations between views are evaluated in one pass, so if view Y is dependent on the position of view X, make sure the view X comes first in the layout.

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.

Also see RelativeLayout.LayoutParams for layout attributes


Nested Class Summary
static class RelativeLayout.LayoutParams
          Per-child layout information associated with RelativeLayout.
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
static int ABOVE
          Rule that aligns a child's bottom edge with another child's top edge.
static int ALIGN_BASELINE
          Rule that aligns a child's baseline with another child's baseline.
static int ALIGN_BOTTOM
          Rule that aligns a child's bottom edge with another child's bottom edge.
static int ALIGN_LEFT
          Rule that aligns a child's left edge with another child's left edge.
static int ALIGN_PARENT_BOTTOM
          Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge.
static int ALIGN_PARENT_LEFT
          Rule that aligns the child's left edge with its RelativeLayout parent's left edge.
static int ALIGN_PARENT_RIGHT
          Rule that aligns the child's right edge with its RelativeLayout parent's right edge.
static int ALIGN_PARENT_TOP
          Rule that aligns the child's top edge with its RelativeLayout parent's top edge.
static int ALIGN_RIGHT
          Rule that aligns a child's right edge with another child's right edge.
static int ALIGN_TOP
          Rule that aligns a child's top edge with another child's top edge.
static int BELOW
          Rule that aligns a child's top edge with another child's bottom edge.
static int CENTER_HORIZONTAL
          Rule that centers the child horizontally with respect to the bounds of its RelativeLayout parent.
static int CENTER_IN_PARENT
          Rule that centers the child with respect to the bounds of its RelativeLayout parent.
static int CENTER_VERTICAL
          Rule that centers the child vertically with respect to the bounds of its RelativeLayout parent.
static int LEFT_OF
          Rule that aligns a child's right edge with another child's left edge.
static int RIGHT_OF
          Rule that aligns a child's left edge with another child's right edge.
static int TRUE
           
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
RelativeLayout(Context context)
           
RelativeLayout(Context context, AttributeSet attrs)
           
RelativeLayout(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
protected  boolean checkLayoutParams(ViewGroup.LayoutParams p)
          
protected  ViewGroup.LayoutParams generateDefaultLayoutParams()
          Returns a set of layout parameters with a width of ViewGroup.LayoutParams.WRAP_CONTENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and no spanning.
 RelativeLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
          Returns a new set of layout parameters based on the supplied attributes set.
protected  ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
          Returns a safe set of layout parameters based on the supplied layout params.
 int getBaseline()
          Return the offset of the widget's text baseline from the widget's top boundary.
protected  void onLayout(boolean changed, int l, int t, int r, int b)
          Called from layout when this view should assign a size and position to each of its children.
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           Measure the view and its content to determine the measured width and the measured height.
 void setGravity(int gravity)
          Describes how the child views are positioned.
 void setHorizontalGravity(int horizontalGravity)
           
 void setIgnoreGravity(int viewId)
          Defines which View is ignored when the gravity is applied.
 void setVerticalGravity(int verticalGravity)
           
 
Methods inherited from class android.view.ViewGroup
addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, findFocus, findViewTraversal, findViewWithTagTraversal, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, showContextMenuForChild, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchKeyShortcutEvent, draw, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCreateContextMenu, onDetachedFromWindow, onDraw, onFinishInflate, onFocusChanged, onKeyDown, onKeyMultiple, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onSizeChanged, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested, requestLayout
 

Field Detail

TRUE

public static final int TRUE
See Also:
Constant Field Values

LEFT_OF

public static final int LEFT_OF
Rule that aligns a child's right edge with another child's left edge.

See Also:
Constant Field Values

RIGHT_OF

public static final int RIGHT_OF
Rule that aligns a child's left edge with another child's right edge.

See Also:
Constant Field Values

ABOVE

public static final int ABOVE
Rule that aligns a child's bottom edge with another child's top edge.

See Also:
Constant Field Values

BELOW

public static final int BELOW
Rule that aligns a child's top edge with another child's bottom edge.

See Also:
Constant Field Values

ALIGN_BASELINE

public static final int ALIGN_BASELINE
Rule that aligns a child's baseline with another child's baseline.

See Also:
Constant Field Values

ALIGN_LEFT

public static final int ALIGN_LEFT
Rule that aligns a child's left edge with another child's left edge.

See Also:
Constant Field Values

ALIGN_TOP

public static final int ALIGN_TOP
Rule that aligns a child's top edge with another child's top edge.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
Rule that aligns a child's right edge with another child's right edge.

See Also:
Constant Field Values

ALIGN_BOTTOM

public static final int ALIGN_BOTTOM
Rule that aligns a child's bottom edge with another child's bottom edge.

See Also:
Constant Field Values

ALIGN_PARENT_LEFT

public static final int ALIGN_PARENT_LEFT
Rule that aligns the child's left edge with its RelativeLayout parent's left edge.

See Also:
Constant Field Values

ALIGN_PARENT_TOP

public static final int ALIGN_PARENT_TOP
Rule that aligns the child's top edge with its RelativeLayout parent's top edge.

See Also:
Constant Field Values

ALIGN_PARENT_RIGHT

public static final int ALIGN_PARENT_RIGHT
Rule that aligns the child's right edge with its RelativeLayout parent's right edge.

See Also:
Constant Field Values

ALIGN_PARENT_BOTTOM

public static final int ALIGN_PARENT_BOTTOM
Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge.

See Also:
Constant Field Values

CENTER_IN_PARENT

public static final int CENTER_IN_PARENT
Rule that centers the child with respect to the bounds of its RelativeLayout parent.

See Also:
Constant Field Values

CENTER_HORIZONTAL

public static final int CENTER_HORIZONTAL
Rule that centers the child horizontally with respect to the bounds of its RelativeLayout parent.

See Also:
Constant Field Values

CENTER_VERTICAL

public static final int CENTER_VERTICAL
Rule that centers the child vertically with respect to the bounds of its RelativeLayout parent.

See Also:
Constant Field Values
Constructor Detail

RelativeLayout

public RelativeLayout(Context context)

RelativeLayout

public RelativeLayout(Context context,
                      AttributeSet attrs)

RelativeLayout

public RelativeLayout(Context context,
                      AttributeSet attrs,
                      int defStyle)
Method Detail

setIgnoreGravity

public void setIgnoreGravity(int viewId)
Defines which View is ignored when the gravity is applied. This setting has no effect if the gravity is Gravity.LEFT | Gravity.TOP.

Parameters:
viewId - The id of the View to be ignored by gravity, or 0 if no View should be ignored.
See Also:
setGravity(int)

setGravity

public void setGravity(int gravity)
Describes how the child views are positioned. Defaults to Gravity.LEFT | Gravity.TOP.

Parameters:
gravity - See Gravity
See Also:
setHorizontalGravity(int), setVerticalGravity(int)

setHorizontalGravity

public void setHorizontalGravity(int horizontalGravity)

setVerticalGravity

public void setVerticalGravity(int verticalGravity)

getBaseline

public int getBaseline()
Description copied from class: View

Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

Overrides:
getBaseline in class View
Returns:
the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Description copied from class: View

Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling the superclass' View.onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override View.onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (View.getSuggestedMinimumHeight() and View.getSuggestedMinimumWidth()).

Overrides:
onMeasure in class View
Parameters:
widthMeasureSpec - horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec - vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
See Also:
View.getMeasuredWidth(), View.getMeasuredHeight(), View.setMeasuredDimension(int, int), View.getSuggestedMinimumHeight(), View.getSuggestedMinimumWidth(), View.MeasureSpec.getMode(int), View.MeasureSpec.getSize(int)

onLayout

protected void onLayout(boolean changed,
                        int l,
                        int t,
                        int r,
                        int b)
Description copied from class: ViewGroup
Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their their children.

Specified by:
onLayout in class ViewGroup
Parameters:
changed - This is a new size or position for this view
l - Left position, relative to parent
t - Top position, relative to parent
r - Right position, relative to parent
b - Bottom position, relative to parent

generateLayoutParams

public RelativeLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
Description copied from class: ViewGroup
Returns a new set of layout parameters based on the supplied attributes set.

Overrides:
generateLayoutParams in class ViewGroup
Parameters:
attrs - the attributes to build the layout parameters from
Returns:
an instance of ViewGroup.LayoutParams or one of its descendants

generateDefaultLayoutParams

protected ViewGroup.LayoutParams generateDefaultLayoutParams()
Returns a set of layout parameters with a width of ViewGroup.LayoutParams.WRAP_CONTENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and no spanning.

Overrides:
generateDefaultLayoutParams in class ViewGroup
Returns:
a set of default layout parameters or null

checkLayoutParams

protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
Description copied from class: ViewGroup

Overrides:
checkLayoutParams in class ViewGroup

generateLayoutParams

protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
Description copied from class: ViewGroup
Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of ViewGroup.checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Overrides:
generateLayoutParams in class ViewGroup
Parameters:
p - The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns:
an instance of ViewGroup.LayoutParams or one of its descendants

Build 1.0_r1(from source)

Please submit a feedback, bug or feature