# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: XML Attrs | Inherited XML Attrs | Inherited Constants | Fields | Inherited Fields | Ctors | Methods | Inherited Methods

# ViewGroup.MarginLayoutParams

`public static class ViewGroup.MarginLayoutParams`
`` `extends ViewGroup.LayoutParams` ``

java.lang.Object
↳ | android.view.ViewGroup.LayoutParams
| ↳ | android.view.ViewGroup.MarginLayoutParams

Known direct subclasses ActionBar.LayoutParams, FrameLayout.LayoutParams, GridLayout.LayoutParams, LinearLayout.LayoutParams, RelativeLayout.LayoutParams
ActionBar.LayoutParams | Per-child layout information associated with action bar custom views.
FrameLayout.LayoutParams | Per-child layout information for layouts that support margins.
GridLayout.LayoutParams | Layout information associated with each of the children of a GridLayout.
LinearLayout.LayoutParams | Per-child layout information associated with ViewLinearLayout.
RelativeLayout.LayoutParams | Specifies how a view is positioned within a `RelativeLayout`.

Known indirect subclasses ActionMenuView.LayoutParams, RadioGroup.LayoutParams, TableLayout.LayoutParams, TableRow.LayoutParams, Toolbar.LayoutParams
ActionMenuView.LayoutParams |
RadioGroup.LayoutParams | This set of layout parameters defaults the width and the height of the children to `ViewGroup.LayoutParams.WRAP_CONTENT` when they are not specified in the XML file.
TableLayout.LayoutParams | This set of layout parameters enforces the width of each child to be `ViewGroup.LayoutParams.MATCH_PARENT` and the height of each child to be `ViewGroup.LayoutParams.WRAP_CONTENT`, but only if the height is not specified.
TableRow.LayoutParams | Set of layout parameters used in table rows.
Toolbar.LayoutParams | Layout information for child views of Toolbars.

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_margin` | Specifies extra space on the left, top, right and bottom sides of this view.
`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_marginHorizontal` | Specifies extra space on the left and right sides 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.
`android:layout_marginVertical` | Specifies extra space on the top and bottom sides of this view.

### Inherited XML attributes
From class `android.view.ViewGroup.LayoutParams`
`android:layout_height` | Specifies the basic height of the view.
`android:layout_width` | Specifies the basic width of the view.

### Inherited constants
From class `android.view.ViewGroup.LayoutParams`
`int` | `FILL_PARENT` Special value for the height or width requested by a View.
`int` | `MATCH_PARENT` Special value for the height or width requested by a View.
`int` | `WRAP_CONTENT` Special value for the height or width requested by a View.

### 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
From class `android.view.ViewGroup.LayoutParams`
`public int` | `height` Information about how tall the view wants to be.
`public LayoutAnimationController.AnimationParameters` | `layoutAnimationParameters` Used to animate layouts.
`public int` | `width` Information about how wide the view wants to be.

### Public constructors
`MarginLayoutParams(Context c, AttributeSet attrs)` Creates a new set of layout parameters.
`MarginLayoutParams(int width, int height)`
`MarginLayoutParams(ViewGroup.MarginLayoutParams source)` Copy constructor.
`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 `View.requestLayout()`.
`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
From class `android.view.ViewGroup.LayoutParams`
`void` | `resolveLayoutDirection(int layoutDirection)` Resolve layout parameters depending on the layout direction.
`void` | `setBaseAttributes(TypedArray a, int widthAttr, int heightAttr)` Extracts the layout parameters from the supplied attributes.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## XML attributes

### android:layout_margin

Specifies extra space on the left, top, right and bottom sides of this view. If both layout_margin and any of layout_marginLeft, layout_marginRight, layout_marginStart, layout_marginEnd, layout_marginTop, and layout_marginBottom are also specified, the layout_margin value will take precedence over the edge-specific values. 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).

### 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:

- `setMargins(int,int,int,int)`

### 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:

- `setMarginEnd(int)`

### android:layout_marginHorizontal

Specifies extra space on the left and right sides of this view. Specifying layout_marginHorizontal is equivalent to specifying layout_marginLeft and layout_marginRight. If both layout_marginHorizontal and either/both of layout_marginLeft and layout_marginRight are also specified, the layout_marginHorizontal value will take precedence over the edge-specific values. Also, layout_margin will always take precedence over any of these values, including layout_marginHorizontal. 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).

### 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:

- `setMargins(int,int,int,int)`

### 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:

- `setMargins(int,int,int,int)`

### 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:

- `setMarginStart(int)`

### 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:

- `setMargins(int,int,int,int)`

### android:layout_marginVertical

Specifies extra space on the top and bottom sides of this view. Specifying layout_marginVertical is equivalent to specifying layout_marginTop and layout_marginBottom with that same value. If both layout_marginVertical and either/both of layout_marginTop and layout_marginBottom are also specified, the layout_marginVertical value will take precedence over the edge-specific values. Also, layout_margin will always take precedence over any of these values, including layout_marginVertical. 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).

## Fields

### bottomMargin

    public int bottomMargin

The bottom margin in pixels of the child. Margin values should be positive. Call `ViewGroup#setLayoutParams(LayoutParams)` after reassigning a new value to this field.

### leftMargin

    public int leftMargin

The left margin in pixels of the child. Margin values should be positive. Call `ViewGroup#setLayoutParams(LayoutParams)` after reassigning a new value to this field.

### rightMargin

    public int rightMargin

The right margin in pixels of the child. Margin values should be positive. Call `ViewGroup#setLayoutParams(LayoutParams)` after reassigning a new value to this field.

### topMargin

    public int topMargin

The top margin in pixels of the child. Margin values should be positive. Call `ViewGroup#setLayoutParams(LayoutParams)` after reassigning a new value to this field.

## Public constructors

### MarginLayoutParams

    public 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

### MarginLayoutParams

    public MarginLayoutParams (int width,
                    int height)

Parameters
`width` | `int`
`height` | `int`

### MarginLayoutParams

    public 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.

### MarginLayoutParams

    public MarginLayoutParams (ViewGroup.LayoutParams source)

Parameters
`source` | `ViewGroup.LayoutParams`

## Public methods

### getLayoutDirection

    public int getLayoutDirection ()

Retuns the layout direction. Can be either `View#LAYOUT_DIRECTION_LTR` or `View#LAYOUT_DIRECTION_RTL`.

Returns
`int` | the layout direction.

### getMarginEnd

    public int getMarginEnd ()

Returns the end margin in pixels.

Related XML Attributes:

- android:layout_marginEnd

Returns
`int` | the end margin in pixels.

### getMarginStart

    public int getMarginStart ()

Returns the start margin in pixels.

Related XML Attributes:

- android:layout_marginStart

Returns
`int` | the start margin in pixels.

### isMarginRelative

    public boolean isMarginRelative ()

Check if margins are relative.

Related XML Attributes:

- android:layout_marginStart
- android:layout_marginEnd

Returns
`boolean` | true if either marginStart or marginEnd has been set.

### resolveLayoutDirection

    public void resolveLayoutDirection (int layoutDirection)

This will be called by `View.requestLayout()`. Left and Right margins may be overridden depending on layout direction.

Parameters
`layoutDirection` | `int`: the direction of the layout `View#LAYOUT_DIRECTION_LTR` `View#LAYOUT_DIRECTION_RTL`

### setLayoutDirection

    public void setLayoutDirection (int layoutDirection)

Set the layout direction

Parameters
`layoutDirection` | `int`: the layout direction. Should be either `View#LAYOUT_DIRECTION_LTR` or `View#LAYOUT_DIRECTION_RTL`.

### setMarginEnd

    public void setMarginEnd (int end)

Sets the relative end margin. Margin values should be positive.

Related XML Attributes:

- android:layout_marginEnd

Parameters
`end` | `int`: the end margin size

### setMarginStart

    public void setMarginStart (int start)

Sets the relative start margin. Margin values should be positive.

Related XML Attributes:

- android:layout_marginStart

Parameters
`start` | `int`: the start margin size

### setMargins

    public void setMargins (int left,
                    int top,
                    int right,
                    int bottom)

Sets the margins, in pixels. A call to `View.requestLayout()` needs to be done so that the new margins are taken into account. Left and right margins may be overridden by `View.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

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*