CloneableAdaptiveBoxLayout.LayoutConfig, DependentLayout.LayoutConfig, DirectionalLayout.LayoutConfig, FlexLayout.LayoutConfig, ListComponent.ListLayoutConfig, MagicLayout.LayoutConfig, SlideDrawer.LayoutConfig, StackLayout.LayoutConfig, TableLayout.LayoutConfigpublic static class ComponentContainer.LayoutConfig extends Object implements Cloneable
The margin layout information of each child component can be provided.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
int |
height |
component height.
|
static int |
MATCH_CONTENT |
MATCH_CONTENT means that the component will be big enough to enclose its content and use its own
padding. |
static int |
MATCH_PARENT |
MATCH_PARENT means that each child component will be the same size as its parent component, but
the parent padding size (if any) needs to be deducted. |
int |
width |
component width.
|
| 构造器 | 说明 |
|---|---|
LayoutConfig() |
Default constructor used to create a
LayoutConfig instance with the width and height set to
MATCH_CONTENT by default. |
LayoutConfig(int width,
int height) |
A constructor used to create a
LayoutConfig instance by specifying width and height. |
LayoutConfig(ComponentContainer.LayoutConfig config) |
A constructor used to create a
LayoutConfig instance from an existing
LayoutConfig instance. |
LayoutConfig(Context context,
AttrSet attrSet) |
Obtains attributes from
AttrSet to instantiate LayoutConfig. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Object |
clone() |
Creates and returns a copy of this object.
|
int |
getHorizontalEndMargin() |
Obtains the end margin.
|
int |
getHorizontalStartMargin() |
Obtains the start margin.
|
Component.LayoutDirection |
getLayoutDirection() |
Returns the layout direction:
LayoutDirection#LTR or
LayoutDirection#RTL |
int |
getMarginBottom() |
Obtains the bottom margin.
|
int |
getMarginLeft() |
Obtains the left margin.
|
int |
getMarginRight() |
Obtains the right margin.
|
int[] |
getMargins() |
Obtains the left, top, right, and bottom margins of the component.
|
int[] |
getMarginsLeftAndRight() |
Obtains horizontal (left and right) margins of the component.
|
int[] |
getMarginsTopAndBottom() |
Obtains vertical (top and bottom) margins of the component.
|
int |
getMarginTop() |
Obtains the top margin.
|
protected boolean |
isMarginsRelative() |
Check if current margins is relative or not.
|
void |
setMarginBottom(int bottom) |
Sets the bottom margin for the component.
|
void |
setMarginLeft(int left) |
Sets the left margin for the component.
|
void |
setMarginRight(int right) |
Sets the right margin for the component.
|
void |
setMargins(int left,
int top,
int right,
int bottom) |
Sets the margins in integers.
|
void |
setMarginsLeftAndRight(int left,
int right) |
Sets horizontal (left and right) margins for the component.
|
void |
setMarginsRelative(int start,
int top,
int end,
int bottom) |
Sets the relative margins in integers.
|
void |
setMarginsTopAndBottom(int top,
int bottom) |
Sets vertical (top and bottom) margins for the component.
|
void |
setMarginTop(int top) |
Sets the top margin for the component.
|
public static final int MATCH_CONTENT
MATCH_CONTENT means that the component will be big enough to enclose its content and use its own
padding.public static final int MATCH_PARENT
MATCH_PARENT means that each child component will be the same size as its parent component, but
the parent padding size (if any) needs to be deducted.public int height
The height can be MATCH_PARENT, MATCH_CONTENT, or a specific value, in unit of pixels.
public int width
The width can be MATCH_PARENT, MATCH_CONTENT, or a specific value in unit of pixels.
public LayoutConfig()
LayoutConfig instance with the width and height set to
MATCH_CONTENT by default.
It sets the width and height of the layout to MATCH_CONTENT.
public LayoutConfig(Context context, AttrSet attrSet)
AttrSet to instantiate LayoutConfig.context - Indicates the application context.attrSet - Indicates the attribute set to obtain.public LayoutConfig(int width,
int height)
LayoutConfig instance by specifying width and height.width - Indicates the width in pixels. The value can be a fixed value, MATCH_CONTENT, or
MATCH_PARENT.height - Indicates the height in pixels. The value can be a fixed value, MATCH_CONTENT, or
MATCH_PARENT.public LayoutConfig(ComponentContainer.LayoutConfig config)
LayoutConfig instance from an existing
LayoutConfig instance.config - Indicates the layout parameters based on which the instance will be created.public Object clone() throws CloneNotSupportedException
x, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except
Object) obey this convention, it will be the case that
x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone for class Object performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable, then a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable and that
the return type of the clone method of an array type T[]
is T[] where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time.
clone 在类中 ObjectCloneNotSupportedException - if the object's class does not
support the Cloneable interface. Subclasses
that override the clone method can also
throw this exception to indicate that an instance cannot
be cloned.Cloneablepublic void setMargins(int left,
int top,
int right,
int bottom)
left - Indicates the left margin, in pixels.top - Indicates the top margin, in pixels.right - Indicates the right margin, in pixels.bottom - Indicates the bottom margin, in pixels.setMarginsRelative(int, int, int, int),
getMarginLeft(),
getMarginTop(),
getMarginRight(),
getMarginBottom()public void setMarginsRelative(int start,
int top,
int end,
int bottom)
start - Indicates the start margin, in pixels.top - Indicates the top margin, in pixels.end - Indicates the end margin, in pixels.bottom - Indicates the bottom margin, in pixels.setMargins(int, int, int, int),
getHorizontalStartMargin(),
getMarginTop(),
getHorizontalEndMargin(),
getMarginBottom()public void setMarginLeft(int left)
left - Indicates the left margin to set, in pixels.public void setMarginTop(int top)
top - Indicates the top margin to set, in pixels.public void setMarginRight(int right)
right - Indicates the right margin to set, in pixels.public void setMarginBottom(int bottom)
bottom - Indicates the bottom margin to set, in pixels.public void setMarginsLeftAndRight(int left,
int right)
left - Indicates the left margin to set, in pixels.right - Indicates the right margin to set, in pixels.public void setMarginsTopAndBottom(int top,
int bottom)
top - Indicates the top margin to set, in pixels.bottom - Indicates the bottom margin to set, in pixels.public int[] getMargins()
setMargins(int, int, int, int)public int[] getMarginsLeftAndRight()
setMarginsLeftAndRight(int, int)public int[] getMarginsTopAndBottom()
setMarginsTopAndBottom(int, int)public int getMarginLeft()
setMargins(int, int, int, int)public int getMarginTop()
setMargins(int, int, int, int)public int getMarginRight()
setMargins(int, int, int, int)public int getMarginBottom()
setMargins(int, int, int, int)public int getHorizontalStartMargin()
setMarginsRelative(int, int, int, int),
getHorizontalEndMargin()public int getHorizontalEndMargin()
setMarginsRelative(int, int, int, int),
getHorizontalStartMargin()protected boolean isMarginsRelative()
true if relative, otherwise false.public Component.LayoutDirection getLayoutDirection()
LayoutDirection#LTR or
LayoutDirection#RTL