ViewGroup.MarginLayoutParams
public
static
class
ViewGroup.MarginLayoutParams
extends ViewGroup.LayoutParams
| java.lang.Object | ||
| ↳ | android.view.ViewGroup.LayoutParams | |
| ↳ | android.view.ViewGroup.MarginLayoutParams | |
|
|
Per-child layout information for layouts that support margins.
See
ViewGroup Margin Layout Attributes
for a list of all child view attributes that this class supports.
Summary
XML attributes | |
|---|---|
android:layout_marginBottom |
Specifies extra space on the bottom side of this view. |
android:layout_marginEnd |
Specifies extra space on the end side of this view. |
android:layout_marginLeft |
Specifies extra space on the left side of this view. |
android:layout_marginRight |
Specifies extra space on the right side of this view. |
android:layout_marginStart |
Specifies extra space on the start side of this view. |
android:layout_marginTop |
Specifies extra space on the top side of this view. |
Inherited XML attributes | |
|---|---|
android.view.ViewGroup.LayoutParams
| |
Inherited constants |
|---|
android.view.ViewGroup.LayoutParams
|
Fields | |
|---|---|
public
int |
bottomMargin
The bottom margin in pixels of the child. |
public
int |
leftMargin
The left margin in pixels of the child. |
public
int |
rightMargin
The right margin in pixels of the child. |
public
int |
topMargin
The top margin in pixels of the child. |
Inherited fields |
|---|
android.view.ViewGroup.LayoutParams
|
Public constructors | |
|---|---|
ViewGroup.MarginLayoutParams(Context c, AttributeSet attrs)
Creates a new set of layout parameters. |
|
ViewGroup.MarginLayoutParams(int width, int height)
|
|
ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams source)
Copy constructor. |
|
ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams source)
|
|
Public methods | |
|---|---|
int
|
getLayoutDirection()
Retuns the layout direction. |
int
|
getMarginEnd()
Returns the end margin in pixels. |
int
|
getMarginStart()
Returns the start margin in pixels. |
boolean
|
isMarginRelative()
Check if margins are relative. |
void
|
resolveLayoutDirection(int layoutDirection)
This will be called by |
void
|
setLayoutDirection(int layoutDirection)
Set the layout direction |
void
|
setMarginEnd(int end)
Sets the relative end margin. |
void
|
setMarginStart(int start)
Sets the relative start margin. |
void
|
setMargins(int left, int top, int right, int bottom)
Sets the margins, in pixels. |
Inherited methods | |
|---|---|
android.view.ViewGroup.LayoutParams
| |
java.lang.Object
| |
XML attributes
android:layout_marginBottom
Specifies extra space on the bottom side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
android:layout_marginEnd
Specifies extra space on the end side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
android:layout_marginLeft
Specifies extra space on the left side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
android:layout_marginRight
Specifies extra space on the right side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
android:layout_marginStart
Specifies extra space on the start side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
android:layout_marginTop
Specifies extra space on the top side of this view. This space is outside this view's bounds. Margin values should be positive.
May be a dimension value, which is a floating point number appended with a
unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels),
sp (scaled pixels based on preferred font size), in (inches), and
mm (millimeters).
Related methods:
Fields
bottomMargin
int bottomMargin
The bottom margin in pixels of the child. Margin values should be positive.
Call setLayoutParams(LayoutParams) after reassigning a new value
to this field.
leftMargin
int leftMargin
The left margin in pixels of the child. Margin values should be positive.
Call setLayoutParams(LayoutParams) after reassigning a new value
to this field.
rightMargin
int rightMargin
The right margin in pixels of the child. Margin values should be positive.
Call setLayoutParams(LayoutParams) after reassigning a new value
to this field.
topMargin
int topMargin
The top margin in pixels of the child. Margin values should be positive.
Call setLayoutParams(LayoutParams) after reassigning a new value
to this field.
Public constructors
ViewGroup.MarginLayoutParams
ViewGroup.MarginLayoutParams (Context c, AttributeSet attrs)
Creates a new set of layout parameters. The values are extracted from the supplied attributes set and context.
| Parameters | |
|---|---|
c |
Context: the application environment |
attrs |
AttributeSet: the set of attributes from which to extract the layout
parameters' values
|
ViewGroup.MarginLayoutParams
ViewGroup.MarginLayoutParams (int width,
int height)
| Parameters | |
|---|---|
width |
int |
height |
int |
ViewGroup.MarginLayoutParams
ViewGroup.MarginLayoutParams (ViewGroup.MarginLayoutParams source)
Copy constructor. Clones the width, height and margin values of the source.
| Parameters | |
|---|---|
source |
ViewGroup.MarginLayoutParams: The layout params to copy from.
|
ViewGroup.MarginLayoutParams
ViewGroup.MarginLayoutParams (ViewGroup.LayoutParams source)
| Parameters | |
|---|---|
source |
ViewGroup.LayoutParams |
Public methods
getLayoutDirection
int getLayoutDirection ()
Retuns the layout direction. Can be either LAYOUT_DIRECTION_LTR or
LAYOUT_DIRECTION_RTL.
| Returns | |
|---|---|
int |
the layout direction. |
getMarginEnd
int getMarginEnd ()
Returns the end margin in pixels.
Related XML Attributes:
| Returns | |
|---|---|
int |
the end margin in pixels. |
getMarginStart
int getMarginStart ()
Returns the start margin in pixels.
Related XML Attributes:
| Returns | |
|---|---|
int |
the start margin in pixels. |
isMarginRelative
boolean isMarginRelative ()
Check if margins are relative.
Related XML Attributes:
| Returns | |
|---|---|
boolean |
true if either marginStart or marginEnd has been set. |
resolveLayoutDirection
void resolveLayoutDirection (int layoutDirection)
This will be called by requestLayout(). Left and Right margins
may be overridden depending on layout direction.
| Parameters | |
|---|---|
layoutDirection |
int: the direction of the layout
LAYOUT_DIRECTION_LTR
LAYOUT_DIRECTION_RTL
|
setLayoutDirection
void setLayoutDirection (int layoutDirection)
Set the layout direction
| Parameters | |
|---|---|
layoutDirection |
int: the layout direction.
Should be either LAYOUT_DIRECTION_LTR
or LAYOUT_DIRECTION_RTL.
|
setMarginEnd
void setMarginEnd (int end)
Sets the relative end margin. Margin values should be positive.
Related XML Attributes:
| Parameters | |
|---|---|
end |
int: the end margin size |
setMarginStart
void setMarginStart (int start)
Sets the relative start margin. Margin values should be positive.
Related XML Attributes:
| Parameters | |
|---|---|
start |
int: the start margin size |
setMargins
void setMargins (int left,
int top,
int right,
int bottom)
Sets the margins, in pixels. A call to requestLayout() needs
to be done so that the new margins are taken into account. Left and right margins may be
overriden by requestLayout() depending on layout direction.
Margin values should be positive.
Related XML Attributes:
- android:layout_marginLeft
- android:layout_marginTop
- android:layout_marginRight
- android:layout_marginBottom
| Parameters | |
|---|---|
left |
int: the left margin size |
top |
int: the top margin size |
right |
int: the right margin size |
bottom |
int: the bottom margin size |
Annotations
Interfaces
- ActionMode.Callback
- ActionProvider.VisibilityListener
- Choreographer.FrameCallback
- CollapsibleActionView
- ContextMenu
- ContextMenu.ContextMenuInfo
- GestureDetector.OnContextClickListener
- GestureDetector.OnDoubleTapListener
- GestureDetector.OnGestureListener
- InputQueue.Callback
- KeyEvent.Callback
- LayoutInflater.Factory
- LayoutInflater.Factory2
- LayoutInflater.Filter
- Menu
- MenuItem
- MenuItem.OnActionExpandListener
- MenuItem.OnMenuItemClickListener
- PixelCopy.OnPixelCopyFinishedListener
- ScaleGestureDetector.OnScaleGestureListener
- SubMenu
- SurfaceHolder
- SurfaceHolder.Callback
- SurfaceHolder.Callback2
- TextureView.SurfaceTextureListener
- View.OnApplyWindowInsetsListener
- View.OnAttachStateChangeListener
- View.OnCapturedPointerListener
- View.OnClickListener
- View.OnContextClickListener
- View.OnCreateContextMenuListener
- View.OnDragListener
- View.OnFocusChangeListener
- View.OnGenericMotionListener
- View.OnHoverListener
- View.OnKeyListener
- View.OnLayoutChangeListener
- View.OnLongClickListener
- View.OnScrollChangeListener
- View.OnSystemUiVisibilityChangeListener
- View.OnTouchListener
- ViewGroup.OnHierarchyChangeListener
- ViewManager
- ViewParent
- ViewStub.OnInflateListener
- ViewTreeObserver.OnDrawListener
- ViewTreeObserver.OnGlobalFocusChangeListener
- ViewTreeObserver.OnGlobalLayoutListener
- ViewTreeObserver.OnPreDrawListener
- ViewTreeObserver.OnScrollChangedListener
- ViewTreeObserver.OnTouchModeChangeListener
- ViewTreeObserver.OnWindowAttachListener
- ViewTreeObserver.OnWindowFocusChangeListener
- Window.Callback
- Window.OnFrameMetricsAvailableListener
- Window.OnRestrictedCaptionAreaChangedListener
- WindowManager
Classes
- AbsSavedState
- ActionMode
- ActionMode.Callback2
- ActionProvider
- Choreographer
- ContextThemeWrapper
- Display
- Display.HdrCapabilities
- Display.Mode
- DragAndDropPermissions
- DragEvent
- FocusFinder
- FrameMetrics
- FrameStats
- GestureDetector
- GestureDetector.SimpleOnGestureListener
- Gravity
- HapticFeedbackConstants
- InputDevice
- InputDevice.MotionRange
- InputEvent
- InputQueue
- KeyboardShortcutGroup
- KeyboardShortcutInfo
- KeyCharacterMap
- KeyCharacterMap.KeyData
- KeyEvent
- KeyEvent.DispatcherState
- LayoutInflater
- MenuInflater
- MotionEvent
- MotionEvent.PointerCoords
- MotionEvent.PointerProperties
- OrientationEventListener
- OrientationListener
- PixelCopy
- PointerIcon
- ScaleGestureDetector
- ScaleGestureDetector.SimpleOnScaleGestureListener
- SearchEvent
- SoundEffectConstants
- Surface
- SurfaceView
- TextureView
- TouchDelegate
- VelocityTracker
- View
- View.AccessibilityDelegate
- View.BaseSavedState
- View.DragShadowBuilder
- View.MeasureSpec
- ViewAnimationUtils
- ViewConfiguration
- ViewDebug
- ViewGroup
- ViewGroup.LayoutParams
- ViewGroup.MarginLayoutParams
- ViewGroupOverlay
- ViewOutlineProvider
- ViewOverlay
- ViewPropertyAnimator
- ViewStructure
- ViewStructure.HtmlInfo
- ViewStructure.HtmlInfo.Builder
- ViewStub
- ViewTreeObserver
- Window
- WindowAnimationFrameStats
- WindowContentFrameStats
- WindowId
- WindowId.FocusObserver
- WindowInsets
- WindowManager.LayoutParams
Enums
Exceptions


