public class LayerElement extends Element
These elements are drawn in list order. Therefore, the
element with the largest index will be drawn on the top of the layer. That element can be defined in an XML file
with the LayerElement are defined in a nested LayerElement has its own bounds and padding that are common for all internal elements. Every internal
element can also have its own bounds, inlays, and size. These properties allow you to position the internal
elements within the LayerElement.
Element.ConstantState, Element.OnBoundsChangeListener, Element.OnChangeListener, Element.OnLayoutDirectionChangeListener, Element.OnRankChangeListener| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
DEPENDENT |
Indicates the mode used to nest each layer element inside the inlay of the previous element.
|
static int |
INDEPENDENT |
Indicates the mode used to nest each layer element inside the inlay of the parent element.
|
ALPHA_DEFAULT, ALPHA_MAX, ALPHA_MIN, DEFAULT_BOUNDS_RECT, MAX_RANK, MIN_RANK| 构造器 | 说明 |
|---|---|
LayerElement() |
Default constructor used to create a
LayerElement. |
LayerElement(Element[] elements) |
A constructor used to create a
LayerElement with a list of specified elements. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
addElement(Element element) |
Adds an element to this
LayerElement. |
int |
getCount() |
Obtains the number of elements within this
LayerElement. |
Optional<Element> |
getElement(int index) |
Obtains the element with the specified index within this
LayerElement. |
int |
getElementAlignment(int index) |
Obtains the alignment used to position or stretch the specified element within its container.
|
int |
getElementHeight(int index) |
Obtains the explicit height of the specified element within this
LayerElement. |
int |
getElementInlayBottom(int index) |
Obtains the inlay from the bottom bound of the specified element.
|
int |
getElementInlayEnd(int index) |
Obtains the inlay from the end bound of the specified element.
|
int |
getElementInlayLeft(int index) |
Obtains the inlay from the left bound of the specified element.
|
int |
getElementInlayRight(int index) |
Obtains the inlay from the right bound of the specified element.
|
int |
getElementInlayStart(int index) |
Obtains the inlay from the start bound of the specified element.
|
int |
getElementInlayTop(int index) |
Obtains the inlay from the top bound of the specified element.
|
int |
getElementWidth(int index) |
Obtains the explicit width of the specified element within this
LayerElement. |
int |
getPaddingBottom() |
Obtains the bottom padding of this
LayerElement. |
int |
getPaddingEnd() |
Obtains the end padding of this
LayerElement. |
int |
getPaddingLeft() |
Obtains the left padding of this
LayerElement. |
int |
getPaddingMode() |
Obtains the padding mode of this
LayerElement. |
int |
getPaddingRight() |
Obtains the right padding of this
LayerElement. |
int |
getPaddingStart() |
Obtains the start padding of this
LayerElement. |
int |
getPaddingTop() |
Obtains the top padding of this
LayerElement. |
Optional<Element> |
getTop() |
Obtains the top element within this
LayerElement. |
int |
replaceElement(int index,
Element element) |
Replaces the element with the specified index within this
LayerElement. |
boolean |
setElementAlignment(int index,
int alignment) |
Sets the alignment used to position or stretch the specified element within its container.
|
boolean |
setElementHeight(int index,
int height) |
Sets an explicit height for the specified element within this
LayerElement. |
boolean |
setElementInlay(int index,
int left,
int top,
int right,
int bottom) |
Sets the inlay for the specified element within this
LayerElement. |
boolean |
setElementInlayRtl(int index,
int start,
int top,
int end,
int bottom) |
Sets the relative inlay for the specified element.
|
boolean |
setElementSize(int index,
int width,
int height) |
Sets an explicit width and height for the specified element within this
LayerElement. |
boolean |
setElementWidth(int index,
int width) |
Sets an explicit width for the specified element within this
LayerElement. |
void |
setPadding(int left,
int top,
int right,
int bottom) |
Sets the absolute padding for this
LayerElement. |
void |
setPaddingMode(int mode) |
Sets the padding mode for this
LayerElement. |
void |
setPaddingRtl(int start,
int top,
int end,
int bottom) |
Sets the relative padding for this
LayerElement. |
clearColorMatrix, drawToCanvas, getAlpha, getBounds, getCallback, getColorMatrix, getCurrentElement, getHeight, getLayoutDirection, getMinHeight, getMinWidth, getPadding, getRank, getStateColorMode, getVisible, getWidth, isInheritDirection, isStateful, isVisible, release, setAlpha, setBounds, setBounds, setCallback, setColorMatrix, setInheritDirection, setLayoutDirection, setOnBoundsChangeListener, setOnLayoutDirectionChangeListener, setOnRankChangeListener, setRank, setStateColor, setStateColorList, setStateColorMode, setVisible, skipAnimationpublic static final int DEPENDENT
public static final int INDEPENDENT
public LayerElement(Element[] elements)
LayerElement with a list of specified elements.elements - Indicates the array of elements to be added as internal items of this LayerElement.public LayerElement()
LayerElement.public int addElement(Element element)
LayerElement.element - Indicates the element to add.-1 if the parameter
is invalid.public int replaceElement(int index,
Element element)
LayerElement.index - Indicates the index of the element to be replaced. The value must be in the range
between 0
and - 1.element - Indicates the element to be used for the replacement.-1 if one of the
parameters is invalid.public Optional<Element> getElement(int index)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().Optional object if the operation is successful; returns an
empty Optional object if
the parameter is invalid.public int getCount()
LayerElement.public boolean setElementSize(int index,
int width,
int height)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().width - Indicates the width to set, in pixels. The value -1 means that the optimal
width will be used.height - Indicates the height to set, in pixels. The value -1 means that the optimal
height will be used.true if the operation is successful; returns false otherwise.public boolean setElementWidth(int index,
int width)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().width - Indicates the width to set, in pixels. The value -1 means that the optimal
width will be used.true if the operation is successful; returns false otherwise.public boolean setElementHeight(int index,
int height)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().height - Indicates the height to set, in pixels. The value -1 means that the optimal
height will be used.true if the operation is successful; returns false otherwise.public int getElementWidth(int index)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementHeight(int index)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public boolean setElementAlignment(int index,
int alignment)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().alignment - Indicates the alignment to set.true if the operation is successful; returns false otherwise.public int getElementAlignment(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 if the parameter is invalid.public boolean setElementInlay(int index,
int left,
int top,
int right,
int bottom)
LayerElement.index - Indicates the index of the element. The value must be in the range between 0
and getCount().left - Indicates the left inlay to add to the left bound of the element, in pixels.top - Indicates the top inlay to add to the top bound of the element, in pixels.right - Indicates the right inlay to add to the right bound of the element, in pixels.bottom - Indicates the bottom inlay to add to the bottom bound of the element, in pixels.true if the operation is successful; returns false otherwise.public boolean setElementInlayRtl(int index,
int start,
int top,
int end,
int bottom)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().start - Indicates the start inlay to add to the start bound of the element, in pixels.top - Indicates the top inlay to add to the top bound of the element, in pixels.end - Indicates the end inlay to add to the end bound of the element, in pixels.bottom - Indicates the bottom inlay to add to the bottom bound of the element, in pixels.true if the operation is successful; returns false otherwise.public int getElementInlayLeft(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementInlayTop(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementInlayRight(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementInlayBottom(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementInlayStart(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public int getElementInlayEnd(int index)
index - Indicates the index of the element. The value must be in the range between 0
and getCount().-1 otherwise.public void setPaddingMode(int mode)
LayerElement.
The padding mode will affect the bounds of each layer in this LayerElement.
mode - Indicates the padding mode to set. The value can be DEPENDENT or INDEPENDENT. The
default value is INDEPENDENT.IllegalArgumentException - Throws this exception if the value of mode is not DEPENDENT or
INDEPENDENT.public int getPaddingMode()
LayerElement.DEPENDENT or INDEPENDENT.public void setPadding(int left,
int top,
int right,
int bottom)
LayerElement.left - Indicates the left padding to set, in pixels.top - Indicates the top padding to set, in pixels.right - Indicates the right padding to set, in pixels.bottom - Indicates the bottom padding to set, in pixels.public void setPaddingRtl(int start,
int top,
int end,
int bottom)
LayerElement.start - Indicates the start padding to set, in pixels.top - Indicates the top padding to set, in pixels.end - Indicates the end padding to set, in pixels.bottom - Indicates the bottom padding to set, in pixels.public int getPaddingLeft()
LayerElement.public int getPaddingTop()
LayerElement.public int getPaddingRight()
LayerElement.public int getPaddingBottom()
LayerElement.public int getPaddingStart()
LayerElement.public int getPaddingEnd()
LayerElement.