ComponentContainer, Image, IndexBar, PageSliderIndicator, ProgressBar, SurfaceProvider, Text, TextureComponentEx, TextureProvider, WebViewpublic class Component extends Object
Each component occupies a rectangular area on the screen and is responsible for drawing and event processing in
this
area. Component is the base class for controls, which are used to create interactive UI components. Its child
class ComponentContainer is the base class for all layouts, which defines layout properties for
other components or component groups.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
Component.BindStateChangedListener |
Provides callbacks to be invoked when a component is bound to or detached from its window.
|
static interface |
Component.CanAcceptScrollListener |
Provides a listener to be invoked to decide a scrolling gesture can be accepted or not.
|
static interface |
Component.ClickedListener |
Provides callbacks to be invoked when a component is clicked.
|
static interface |
Component.ComponentStateChangedListener |
Provides a callback for state change events of a component.
|
static interface |
Component.ContourRefreshedListener |
Provides a listener for callbacks used to set a custom
Contour object for a component. |
static class |
Component.DefSpeechEventListener |
Provides a default callback to be invoked when a voice event is bound to a component.
|
static interface |
Component.DoubleClickedListener |
Provides callbacks to be invoked when a component is double-clicked.
|
static class |
Component.DragFeedbackProvider |
Provides an image (called a "drag shadow") that the system displays during the drag and drop operation.
|
static interface |
Component.DraggedListener |
Provides callbacks to be invoked when a drag event is dispatched to a component by a gesture recognizer.
|
static interface |
Component.DrawTask |
Implements a draw task.
|
static interface |
Component.EditEventListener |
Provides listeners to process editing events triggered by keyboard shortcuts when they are distributed to
components.
|
static interface |
Component.EstimateSizeListener |
Provides an interface for customizing the size (width/height) estimating process.
|
static class |
Component.EstimateSpec |
Defines the measure specifications of a component.
|
static class |
Component.FadeEffectEnum |
Enumerates the types of component indicators to which the fade-out effect can apply.
|
static interface |
Component.FocusChangedListener |
Provides a callback to be invoked when the focus state of a component changes.
|
static interface |
Component.ForwardHoverListener |
Provides a callback to be invoked before a mouse hover event is forwarded to child component.
|
static interface |
Component.ForwardTouchListener |
Provides a callback to be invoked before a touch event is forwarded to child component.
|
static class |
Component.GestureType |
Enumerates gesture type.
|
static interface |
Component.HoverEventListener |
Provides a callback to be invoked when a hover event is dispatched from a component.
|
static interface |
Component.KeyEventListener |
Provides a callback to be invoked when a key event is dispatched from a component.
|
static class |
Component.LayoutDirection |
Enumerates horizontal layout directions.
|
static interface |
Component.LayoutRefreshedListener |
Provides a callback to be invoked when the component is laid out again.
|
static interface |
Component.LongClickedListener |
Provides a callback to be invoked when a long touch event is dispatched from a component.
|
static class |
Component.MeasureSpec |
已过时。
This change is effective since API version 6. Replaced by
EstimateSpec |
static interface |
Component.MouseEventListener |
Provides a callback to be invoked when a mouse event is dispatched from a component.
|
static interface |
Component.MousePointerStyleListener |
Provides a listener to observe mouse pointer style changes.
|
static interface |
Component.OnDragListener |
Callback to be invoked when a drag event is dispatched to a component.
|
static interface |
Component.RotationEventListener |
Provides a callback to be invoked when a rotation event is dispatched from a component.
|
static interface |
Component.ScaledListener |
Provides callbacks for scale events of a component.
|
static interface |
Component.ScrolledListener |
Provides a callback to be invoked when a scroll event is dispatched from a component.
|
static class |
Component.ShadowDevice |
Indicates the shadow device of the window.
|
static class |
Component.ShadowMode |
Indicates the shadow mode of the window.
|
static class |
Component.ShadowSize |
Indicates the shadow size of the window.
|
static interface |
Component.SpeechEventListener |
Provides a callback to be invoked when a voice event is bound to a component.
|
static interface |
Component.TouchEventListener |
Provides a callback to be invoked when a touch event is dispatched to a component.
|
static interface |
Component.UnconsumedKeyEventListener |
Provides a listener to dispatch keyboard event if it hasn't been consumed.
|
static class |
Component.VoiceEvent |
Provides voice events for a component.
|
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
ACCESSIBILITY_ADAPTABLE |
Indicates that this component can be accessed.
|
static int |
ACCESSIBILITY_DISABLE |
Indicates that this component cannot be accessed.
|
static int |
ACCESSIBILITY_ENABLE |
Indicates that this component is enabled.
|
static int |
AXIS_X |
Indicates the x-axis.
|
static int |
AXIS_Y |
Indicates the y-axis.
|
static Component.ContourRefreshedListener |
CONTOUR_BACKGROUND |
Default ContourRefreshedListener for Component.
|
static Component.ContourRefreshedListener |
CONTOUR_BORDER |
Providers a contour that match rectangle border of component.
|
static Component.ContourRefreshedListener |
CONTOUR_PADDING_BORDER |
Providers a contour that match rectangle padding border of component.
|
static float |
DEFAULT_SCALE |
Indicates the default zoom factor for scaling a component.
|
static int |
DRAG_DOWN |
Indicates the scroll bar is dragged downwards.
|
static int |
DRAG_HORIZONTAL |
Indicates that the scroll bar is dragged horizontally.
|
static int |
DRAG_HORIZONTAL_VERTICAL |
Indicates that the scroll bar is dragged horizontally and vertically.
|
static int |
DRAG_LEFT |
Indicates that the scroll bar is dragged leftwards.
|
static int |
DRAG_RIGHT |
Indicates that the scroll bar is dragged rightwards.
|
static int |
DRAG_UP |
Indicates that the scroll bar is dragged upwards.
|
static int |
DRAG_VERTICAL |
Indicates that the scroll bar is dragged vertically.
|
static int |
EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED |
Represents an event indicating that the accessibility focus is obtained.
|
static int |
EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR |
Represents an event indicating that the accessibility focus is cleared.
|
static int |
EVENT_TYPE_COMPONENT_CLICKED |
Represents an event indicating that the component is clicked.
|
static int |
EVENT_TYPE_COMPONENT_FOCUSED |
Represents an event indicating that the component gets the focus.
|
static int |
EVENT_TYPE_COMPONENT_LONG_CLICKED |
Represents an event indicating that the component is long pressed.
|
static int |
EVENT_TYPE_COMPONENT_SCROLLED |
Represents an event indicating that the component is scrolled.
|
static int |
EVENT_TYPE_COMPONENT_SELECTED |
Represents an event indicating that the component is selected.
|
static int |
EVENT_TYPE_COMPONENT_TEXT_UPDATE |
Represents an event indicating that the text in the Text component is changed.
|
static int |
EVENT_TYPE_NOTICE |
Represents an event indicating that the application sends a notice.
|
static int |
EVENT_TYPE_NOTIFICATION_STATE_UPDATE |
Represents an event indicating that a notification is displayed.
|
static int |
EVENT_TYPE_TOAST_SHOW |
Represents an event indicating that a toast is displayed.
|
static int |
EVENT_TYPE_WINDOW_STATE_UPDATE |
Represents an event indicating that the window state is updated.
|
static int |
FOCUS_ADAPTABLE |
The component determines focusability by itself.
|
static int |
FOCUS_DISABLE |
The component does not need keystrokes.
|
static int |
FOCUS_ENABLE |
The component needs keystrokes.
|
static int |
FOCUS_NEXT |
Moves focus to the next clickable item.
|
static int |
FOCUS_PREVIOUS |
Moves focus to the previous clickable item.
|
static int |
FOCUS_SIDE_BOTTOM |
Moves focus down.
|
static int |
FOCUS_SIDE_LEFT |
Moves focus to the left.
|
static int |
FOCUS_SIDE_RIGHT |
Moves focus to the right.
|
static int |
FOCUS_SIDE_TOP |
Moves focus up.
|
static int |
HIDE |
The component is invisible and does not occupy any space for layout purposes.
|
static int |
HORIZONTAL |
Indicates the horizontal orientation mode.
|
static int |
ID_DEFAULT |
Default ID of a component.
|
static int |
INHERITED_MODE |
Indicates that the component uses its parent component's showing mode.
|
static int |
INVISIBLE |
The component is invisible but still occupies space for layout purposes.
|
protected Element |
mBackgroundElement |
Indicates the element object drawn in a component's background.
|
protected Canvas |
mCanvasForTaskOverContent |
The canvas used for custom drawing task between content and foreground.
|
protected Canvas |
mCanvasForTaskUnderContent |
The canvas used for custom drawing task between background and content.
|
protected ComponentParent |
mComponentParent |
Indicates the parent layout for a component.
|
protected Context |
mContext |
Indicates the context.
|
protected Component.DrawTask |
mDrawTaskOverContent |
Customizes a drawing task between the content and the foreground.
|
protected Component.DrawTask |
mDrawTaskUnderContent |
Customizes a drawing task between the content and the background.
|
protected Component.EstimateSizeListener |
mEstimateSizeListener |
Customizes component's width and height during component's estimating size process
|
protected Element |
mForegroundElement |
Indicates the element object drawn in a component's foreground.
|
protected Component.ForwardHoverListener |
mForwardHoverListener |
Indicates the callback invoked when a mouse hover event is forwarded.
|
protected Component.HoverEventListener |
mHoverEventListener |
Indicates the callback invoked when receiving a mouse hover event.
|
protected Component.KeyEventListener |
mKeyEventListener |
Indicates the callback invoked when focused component receiving a key event.
|
protected Component.MouseEventListener |
mMouseEventListener |
Indicates the callback invoked when receiving a mouse event.
|
protected float[] |
mPosition |
Creates the float value for a position.
|
protected Component.RotationEventListener |
mRotationEventListener |
Indicates the callback invoked when receiving a rotation event.
|
protected ShadowElement |
mShadowElement |
Indicates the element object drawn in a component's shadowstyle.
|
protected Component.UnconsumedKeyEventListener |
mUnconsumedKeyEventListener |
Indicates the callback invoked when receiving an unconsumed key event.
|
static int |
OVAL_MODE |
Indicates that the component content is displayed in an ellipse.
|
static int |
OVAL_SCROLL_BAR_MODE |
Indicates that the scrollbar is displayed as an ellipse.
|
protected static int |
POSITION_X_INDEX |
The X-axis coordinate in the position array.
|
protected static int |
POSITION_Y_INDEX |
The Y-axis coordinate in the position array.
|
static int |
RECT_MODE |
Indicates that the component content is displayed in a rectangle.
|
static int |
RECT_SCROLL_BAR_MODE |
Indicates that the scrollbar is displayed as a rectangle.
|
static int |
SCROLL_AUTO_STAGE |
Indicates that the component scrolls inertially in response to a dedicated
operation (for example, fling or rebounding).
|
static int |
SCROLL_IDLE_STAGE |
Indicates that scrolling has come to an end and the component is in the idle state.
|
static int |
SCROLL_NORMAL_STAGE |
Indicates that the component scrolls naturally in response to an external
operation (for example, user touch input).
|
static int |
UNSPECIFIED_SCROLL_BAR_MODE |
Indicates that the mode of the scrollbar follows that of the showing component.
|
static int |
VERTICAL |
Indicates the vertical orientation mode.
|
static int |
VISIBLE |
The component is visible.
|
| 构造器 | 说明 |
|---|---|
Component(Context context) |
Default constructor used to create a
Component instance by using the default attribute set and style. |
Component(Context context,
AttrSet attrSet) |
A constructor used to create a
Component instance by using specified attribute set and default style
after the XML file is parsed. |
Component(Context context,
AttrSet attrSet,
int resId) |
A constructor used to create a
Component instance based on the context, attribute set, and
default theme after the XML file is parsed. |
Component(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
Component instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addDrawTask(Component.DrawTask task) |
Adds a drawing task between the foreground and the component content.
|
void |
addDrawTask(Component.DrawTask task,
int layer) |
Adds a draw task.
|
void |
addScrolledListener(Component.ScrolledListener listener) |
Adds a listener to listen for scrolling events reported when the scrolling stage or position
of the component has changed.
|
void |
announceAccessibility(String text) |
Sets text for an accessibility event of the
TYPE_ANNOUNCEMENT type. |
void |
arrange(int left,
int top,
int width,
int height) |
Positioning the component relatively to the parent layout.
|
CornerMark |
bindCornerMark() |
Sets the corner mark object to be displayed on top of the component.
|
boolean |
callOnClick() |
Calls the assigned OnClickListener.
|
boolean |
canScroll(int orientation) |
Checks whether the component can be scrolled in the specified direction.
|
void |
clearFocus() |
Requests giving up focus.
|
AnimatorProperty |
createAnimatorProperty() |
Creates a property animator object associated with a component.
|
void |
disableFadeEffect(Component.FadeEffectEnum fadeEffectEnum) |
Disables the fade-out effect of the scroll bar or boundary indicator when the component is not scrolled.
|
protected void |
dispatchRestoreState(PlainArray<Sequenceable> stateContainer) |
Distribute the state restore process to restore the states of this component and its child components.
|
protected void |
dispatchSaveState(PlainArray<Sequenceable> stateContainer) |
Distribute the state saving process to save the states of this component and its child components.
|
void |
draw(Canvas canvas) |
Draws this component and its child components on a canvas.
|
void |
enableCornerMark(boolean enable) |
Enables or disables the corner mark for the current component.
|
void |
enableFadeEffect(Component.FadeEffectEnum fadeEffectEnum) |
Enables the fade-out effect of the scroll bar or boundary indicator when the component is not scrolled.
|
void |
enableSaveState(boolean isEnabled) |
Sets whether this component and its child components can save their states.
|
void |
enableScrollBar(int direction,
boolean enabled) |
Sets whether to enable the scroll bar for this component.
|
void |
estimateSize(int widthEstimatedConfig,
int heightEstimatedConfig) |
Sets components's width and height sizes and requirements
|
boolean |
executeDoubleClick() |
Executes the double-click event occurring in this component.
|
boolean |
executeLongClick() |
Performs a long-click event in a component.
|
<T extends Component> |
findComponentById(int id) |
Finds the component with the given ID.
|
ComponentHolder |
findComponentHolderById(int resId) |
Obtains the
ComponentHolder instance using the resource ID. |
Component |
findFocus() |
Obtains the component that currently has focus among its descendant components and itself.
|
Component |
findNextFocusableComponent(int direction) |
Finds the next component to take focus.
|
boolean |
findRequestNextFocus(int side) |
Finds the next component to gain focus and requests focus for it.
|
int |
getAccessibility() |
Obtains the accessibility state.
|
String |
getAccessibilityDescription() |
Obtains the accessibility description of this component.
|
float |
getAlpha() |
Obtains the alpha value of a component.
|
float |
getAltitude() |
Obtains the basic depth location of this component in the direction perpendicular to the screen.
|
Element |
getBackgroundElement() |
Obtains element in the component's background.
|
int |
getBaseLine() |
Obtains the height from the baseline of the text to the top of the component.
|
int |
getBottom() |
Obtains the bottom edge position of a component relative to the parent layout.
|
float |
getBoundaryFadeEffectBottomRate() |
Obtains the rate multiplied by the basic boundary width to obtain the bottom boundary width of the component's
fade-effect area.
|
float |
getBoundaryFadeEffectLeftRate() |
Obtains the rate multiplied by the basic boundary width to obtain the left boundary width of the component's
fade-effect area.
|
float |
getBoundaryFadeEffectRightRate() |
Obtains the rate multiplied by the basic boundary width to obtain the right boundary width of the component's
fade-effect area.
|
float |
getBoundaryFadeEffectTopRate() |
Obtains the rate multiplied by the basic boundary width to obtain the top boundary width of the component's
fade-effect area.
|
float[] |
getCenterZoomFactor() |
Obtains the zoom factor for scaling the center component item.
|
boolean |
getCentralScrollMode() |
Obtains the state of the central scroll mode.
|
Component.ClickedListener |
getClickedListener() |
Obtains a listener for monitoring click events of this component.
|
boolean |
getClipEnabled() |
Checks whether automatic clipping of this component is enabled when it exceeds its parent layout.
|
CharSequence |
getComponentDescription() |
Obtains the description of the content in a component.
|
DimensFloat |
getComponentMinSize() |
Obtains the possible minimum size of this component.
|
ComponentParent |
getComponentParent() |
Obtains the parent layout of a component.
|
Rect |
getComponentPosition() |
Obtains the component's position relative to the parent layout.
|
DimensFloat |
getComponentSize() |
Obtains the component size.
|
Component.ComponentStateChangedListener |
getComponentStateChangedListener() |
Obtains a listener for monitoring state changes of this component.
|
ComponentTreeObserver |
getComponentTreeObserver() |
Obtains the
ComponentTreeObserver for the component. |
boolean |
getContentEnable() |
Obtains whether the content of the component will be drawn.
|
float[] |
getContentPosition() |
Obtains the positions when drawing.
|
float |
getContentPositionX() |
Obtains the X-axis coordinate.
|
float |
getContentPositionY() |
Obtains the Y-axis coordinate.
|
Context |
getContext() |
Obtains the context object held by this component.
|
Contour |
getContour() |
Obtains the
Contour object of the current component. |
Component.ContourRefreshedListener |
getContourRefreshedListener() |
Obtains the listener for updates on the
Contour object of a component. |
CornerMark |
getCornerMark() |
Obtains the corner mark object of the component.
|
float |
getDragAcceptAngle() |
Obtains the deflection angle set for a horizontal or vertical drag recognizer.
|
Component.DraggedListener |
getDraggedListener() |
Obtains a listener for monitoring drag events of this component.
|
Component.EditEventListener |
getEditEventListener() |
Obtains the listener that observes the editing events that are triggered by keyboard shortcuts and
distributed to this component.
|
int |
getEstimatedHeight() |
Returns the estimated height for component.
|
int |
getEstimatedWidth() |
Returns the estimated width for component.
|
int |
getFadeEffectBoundaryWidth() |
Obtains the boundary width of the component's fade-effect area.
|
Color |
getFadeEffectColor() |
Obtains the color displayed when producing the fade effect.
|
int |
getFocusable() |
Obtains the focusable setting of the component.
|
boolean |
getFocusBorderEnable() |
Checks whether the focus border is displayed when this component is in focus.
|
int |
getFocusBorderPadding() |
Obtains the padding between the focus border and this component.
|
float[] |
getFocusBorderRadius() |
Obtains the radii of the focus border's four corners.
|
int |
getFocusBorderWidth() |
Obtains the width of the focus border.
|
Element |
getForegroundElement() |
Obtains element in the component's foreground.
|
int |
getForegroundGravity() |
已过时。
This change is effective since API version 6. This method is redundant and is therefore deprecated.
|
Component.ForwardHoverListener |
getForwardHoverListener() |
Obtains a listener for forward mouse hover events of this component.
|
Component.ForwardTouchListener |
getForwardTouchListener() |
Obtains a listener for forward touch events of this component.
|
int |
getGesturePriority(Component.GestureType gestureType) |
Gets the priority of gestures.
|
int |
getHeight() |
Obtains the height of a component.
|
int[] |
getHorizontalPadding() |
Obtains the horizontal padding of this component.
|
int[] |
getHorizontalPosition() |
Obtains the component's horizontal position relative to the parent layout.
|
Component.HoverEventListener |
getHoverEventListener() |
Obtains a listener for monitoring hover events of this component.
|
int |
getId() |
Obtains the unique ID of the component.
|
Component.KeyEventListener |
getKeyEventListener() |
Obtains a listener for monitoring key events of this component.
|
ComponentContainer.LayoutConfig |
getLayoutConfig() |
Obtains the layout parameters associated with a component.
|
Component.LayoutDirection |
getLayoutDirection() |
Obtains the layout direction of this component.
|
Component.LayoutDirection |
getLayoutDirectionResolved() |
Obtains the resolved layout direction of this component.
|
Component.LayoutRefreshedListener |
getLayoutRefreshedListener() |
Obtains a listener for monitoring layout refresh of this component.
|
int |
getLeft() |
Obtains the left edge position of a component relative to the parent layout.
|
int[] |
getLocationOnScreen() |
Obtains the absolute position of a component on the screen.
|
int |
getMarginBottom() |
Obtains the bottom margin of this component.
|
int |
getMarginLeft() |
Obtains the left margin of this component.
|
int |
getMarginRight() |
Obtains the right margin of this component.
|
int[] |
getMargins() |
Obtains the left, top, right, and bottom margins of this component.
|
int[] |
getMarginsLeftAndRight() |
Obtains horizontal margins of this component.
|
int[] |
getMarginsTopAndBottom() |
Obtains vertical margins of this component.
|
int |
getMarginTop() |
Obtains the top margin of this component.
|
Matrix |
getMatrix() |
Obtains the conversion matrix of the current component.
|
int |
getMinHeight() |
Obtains the minimum possible height of the component.
|
int |
getMinWidth() |
Obtains the minimum possible width of the component.
|
int |
getMode() |
Obtains the showing mode of this component.
|
int |
getModeResolved() |
Obtains the display mode of the device holding this component.
|
Component.MouseEventListener |
getMouseEventListener() |
Obtains a listener for monitoring mouse events of this component.
|
Component.MousePointerStyleListener |
getMousePointerStyleListener() |
Obtains a listener for mouse pointer style changes.
|
String |
getName() |
Obtains the name of the component.
|
int[] |
getPadding() |
Obtains the padding of this component.
|
int |
getPaddingBottom() |
Obtains the bottom padding of the component.
|
int |
getPaddingEnd() |
Obtains the end padding of the component depending on its resolved layout direction.
|
int |
getPaddingLeft() |
Obtains the left padding of the component.
|
int |
getPaddingRight() |
Obtains the right padding of the component.
|
int |
getPaddingStart() |
Obtains the start padding of the component depending on its resolved layout direction.
|
int |
getPaddingTop() |
Obtains the top padding of the component.
|
Point |
getPivot() |
Obtains the pivot relative to the parent layout.
|
float |
getPivotX() |
Obtains the X-axis coordinate of the point around which the component is rotated and scaled, that is, the
pivot point.
|
float |
getPivotY() |
Obtains the Y-axis coordinate of the pivot point relative to the parent layout.
|
ResourceManager |
getResourceManager() |
Obtains the resource manager associated with the context.
|
int |
getRight() |
Obtains the right edge position of a component relative to the parent layout.
|
float |
getRotation() |
Obtains the degrees that the component is rotated around the Z axis relative to the parent layout.
|
Component.RotationEventListener |
getRotationEventListener() |
Obtains a listener for monitoring rotation events of this component.
|
float |
getRotationSensitivity() |
Obtains the rotation sensitivity of a component.
|
DimensFloat |
getScale() |
Obtains the component's scale factor around the pivot relative to the parent layout.
|
Component.ScaledListener |
getScaledListener() |
Obtains a listener for monitoring scale events of this component.
|
float |
getScaleX() |
Obtains the component's scaling factor in the X direction around the pivot point relative to the parent layout.
|
float |
getScaleY() |
Obtains the component's scaling factor in the Y direction around the pivot point relative to the parent layout.
|
Color |
getScrollbarBackgroundColor() |
Obtains the background color of a scroll bar.
|
Color |
getScrollbarColor() |
Obtains the color of a scroll bar.
|
int |
getScrollbarFadingDelay() |
Obtains the delay before a scrollbar is fading.
|
int |
getScrollbarFadingDuration() |
Obtains the fading duration of a scrollbar.
|
int |
getScrollBarMode() |
Obtains the mode of the scrollbar that is being displayed.
|
float |
getScrollbarRadius() |
Obtains the radius of the scroll bar's rounded border.
|
boolean |
getScrollbarRoundRect() |
Obtains the rounded border of the scroll bar.
|
float |
getScrollbarStartAngle() |
Obtains the start angle of a rounded scroll bar.
|
float |
getScrollbarSweepAngle() |
Obtains the sweep angle of a rounded scroll bar.
|
int |
getScrollbarThickness() |
Obtains the thickness of a scroll bar.
|
int |
getScrollState() |
Obtaining the Component Scrolling Status.
|
int |
getScrollValue(int direction) |
Obtains the scroll offset of this component.
|
boolean |
getSelfVisibleRect(Rect rect) |
Allows to get local visible Rect (related to component's parent)
|
Color |
getShadowColor() |
Obtains the shadow's color of
Component. |
Component.SpeechEventListener |
getSpeechEventListener() |
Obtains the listener set by
setSpeechEventListener(ohos.agp.components.Component.SpeechEventListener). |
Object |
getTag() |
Obtains the tag of a component.
|
int |
getTop() |
Obtains the top edge position of a component relative to the parent layout.
|
Component.TouchEventListener |
getTouchEventListener() |
Obtains a listener for monitoring touch events of this component.
|
String |
getTransitionSymbol() |
Gets transition symbol.
|
DimensFloat |
getTranslation() |
Obtains the component's horizontal translation relative to its left boundary and the vertical translation
relative to its top boundary.
|
float |
getTranslationX() |
Obtains the horizontal translation of the component relative to its left position.
|
float |
getTranslationY() |
Obtains the vertical translation of the component relative to its top position.
|
float |
getTranslationZ() |
Obtains the depth location change of this component in the direction perpendicular to the screen.
|
int |
getUserNextFocus(int side) |
Obtains the ID of the next component to give focus to.
|
int[] |
getVerticalPadding() |
Obtains the vertical padding of this component.
|
int[] |
getVerticalPosition() |
Obtains the component's position relative to the parent layout.
|
int |
getVisibility() |
Obtains the visibility of a component.
|
boolean |
getVisibleRectOnScreen(Rect rect,
int[] position) |
Obtains the visible rectangle area of a component in relative to the upper left corner of the screen.
|
int |
getWidth() |
Obtains the width of a component.
|
boolean |
getWindowVisibleRect(Rect visibleRect) |
Obtain the visible rect of the window where the component is located.
|
boolean |
hasFocus() |
Returns whether the component has focus.
|
boolean |
hasFocusedEffect() |
Checks whether a focus effect is displayed for this component when it gains focus.
|
boolean |
hasOverlaps() |
Checks whether this component has overlapping content.
|
void |
hideFocusBorder() |
已过时。
This change is effective since API version 8. This method is redundant and temporary and is
therefore deprecated.
|
void |
informConfigurationChanged(Configuration config) |
Dispatches a configuration change event.
|
void |
invalidate() |
Invalidates a component.
|
boolean |
isBoundaryFadeEffectEnable() |
已过时。
This change is effective since API version 6. Replaced by
isFadeEffected(FadeEffectEnum) |
boolean |
isBoundToWindow() |
Checks whether the component has been bound to a window.
|
boolean |
isClickable() |
Returns whether the component responds to click events or not.
|
boolean |
isClipToContourEnabled() |
Checks whether the
Contour object of a component can be used for content clipping. |
boolean |
isComponentDisplayed() |
Checks whether the component can be displayed.
|
boolean |
isEnabled() |
Obtains the enabled state of the component.
|
boolean |
isFadeEffected(Component.FadeEffectEnum fadeEffectEnum) |
Checks whether the fade-out effect is enabled for the scroll bar or boundary indicator.
|
boolean |
isFocusable() |
Returns whether the component can currently receive focus.
|
boolean |
isFocused() |
Returns whether the component has been focused.
|
boolean |
isIdentityMatrix() |
Checks whether the conversion matrix of the current component is an identity matrix.
|
boolean |
isLongClickOn() |
Returns whether the component is long clickable.
|
boolean |
isPressed() |
Returns whether the component is currently in pressed state.
|
boolean |
isRtl() |
Checks whether the component is laid out from right to left.
|
boolean |
isSaveStateEnabled() |
Checks whether this component and its child components can save their states.
|
boolean |
isScrollbarFadingOn() |
已过时。
This change is effective since API version 6. Replaced by
isFadeEffected(FadeEffectEnum) |
boolean |
isScrollBarOn(int direction) |
Checks whether the scroll bar is enabled for this component.
|
boolean |
isScrollbarOverlapEnabled() |
Checks whether the scroll bar overlaps with the content.
|
boolean |
isSelected() |
Obtains the selection state of the component.
|
boolean |
isSoundEnable() |
Checks whether the sound is played when this component is being clicked.
|
boolean |
isTouchFocusable() |
Returns whether the component can receive focus in touch mode.
|
boolean |
isVibrationEffectEnabled() |
Checks whether vibration effect is enabled.
|
void |
notifyAccessibility(int eventType) |
Triggers an accessibility event specified by this component.
|
protected void |
onAttributeConfigChanged(Configuration config) |
Called when a configuration is changed.
|
boolean |
onDrag(Component component,
DragEvent event) |
Called when a drag event is dispatched to the component.
|
protected void |
onRestoreState(Sequenceable state) |
Called when the states of this component and its child components are to be restored.
|
protected void |
onRtlChanged(Component.LayoutDirection layoutDirection) |
Called when any RTL property has been changed.
|
protected Sequenceable |
onSaveState() |
Called when the states of this component and its child components are to be saved.
|
boolean |
performScale() |
Performs a scale event in a component.
|
void |
playSound(int soundId) |
Plays a sound for this component.
|
void |
postLayout() |
Requests rearranging the layout of the component.
|
void |
refreshContour() |
Refresh the current
Contour object of a component and triggers
ContourRefreshedListener#onContourRefreshed(Component) for setting a custom Contour object. |
void |
release() |
Releases resources.
|
void |
removeBindStateChangedListener(Component.BindStateChangedListener listener) |
Removes a listener for bind state changes.
|
void |
removeScrolledListener(Component.ScrolledListener listener) |
Deletes a listener that listens for scrolling events.
|
boolean |
requestFocus() |
Requests focus for the current component or one of its child components.
|
void |
requestForceForwardTouchEvent(boolean forceForward) |
Called when a component want this parent and its ancestors to keep forwarding following touch events.
|
void |
restoreComponentTreeState(PlainArray<Sequenceable> stateContainer) |
Restores the states of this component and its child components from a given container.
|
void |
saveComponentTreeState(PlainArray<Sequenceable> stateContainer) |
Saves the states of this component and its child components into a given container.
|
void |
scrollBy(int x,
int y) |
Sets the offset by which the component is scrolled.
|
void |
scrollTo(int x,
int y) |
Sets the target position you want the component to scroll to.
|
void |
setAccessibility(int flag) |
Sets the accessibility state.
|
void |
setAccessibilityDescription(String description) |
Sets the description of the accessibility mode for this component.
|
void |
setAlpha(float alpha) |
Sets the alpha value of the component.
|
void |
setAltitude(float altitude) |
Sets the basic depth location of this component in the direction perpendicular to the screen.
|
void |
setBackground(Element element) |
Sets a specified element as the background of the component.
|
void |
setBindStateChangedListener(Component.BindStateChangedListener listener) |
Adds a listener for bind state changes.
|
void |
setBottom(int bottom) |
Sets the bottom edge position of a component relative to the parent container.
|
void |
setBoundaryFadeEffectEnable(boolean enable) |
已过时。
This change is effective since API version 6. Replaced by
enableFadeEffect(FadeEffectEnum) or disableFadeEffect(FadeEffectEnum) |
void |
setCanAcceptScrollListener(Component.CanAcceptScrollListener listener) |
|
void |
setCenterZoomFactor(float scaleX,
float scaleY) |
Sets the zoom factor for scaling the center component item.
|
void |
setCentralScrollMode(boolean centralMode) |
Sets whether to enable the central scroll mode to always display a component item at the center of a component.
|
void |
setClickable(boolean clickable) |
Enables or disables click events for the component.
|
void |
setClickedListener(Component.ClickedListener listener) |
Registers a listener for click events in the component.
|
void |
setClipEnabled(boolean enabled) |
Sets whether to allow automatic clipping of the component in case it exceeds its parent layout.
|
void |
setClipToContourEnabled(boolean enable) |
Sets whether the
Contour object of a component can be used for content clipping. |
void |
setComponentDescription(CharSequence componentDescription) |
Sets a description of the content in a component.
|
void |
setComponentMinSize(int minWidth,
int minHeight) |
Sets the minimum possible width and height for this component.
|
void |
setComponentPosition(int left,
int top,
int right,
int bottom) |
Sets the component's position relative to the parent container.
|
void |
setComponentPosition(Rect rect) |
Sets the component's position relative to the parent container based on
rect. |
void |
setComponentSize(int width,
int height) |
Sets the component size.
|
void |
setComponentStateChangedListener(Component.ComponentStateChangedListener listener) |
Sets the listener for state change events of a component.
|
void |
setContentEnable(boolean enable) |
Sets whether to draw content for a component.
|
void |
setContentPosition(float x,
float y) |
Sets positions for drawing and event listening.
|
void |
setContentPositionX(float x) |
Sets the x-coordinate for drawing and event listening.
|
void |
setContentPositionY(float y) |
Sets the y-coordinate for drawing and event listening.
|
void |
setContour(Contour contour) |
Sets a custom
Contour object for the component. |
void |
setContourRefreshedListener(Component.ContourRefreshedListener listener) |
Registers a listener for updates on the
Contour object of a component. |
void |
setDoubleClickedListener(Component.DoubleClickedListener listener) |
Registers a listener for monitoring double-click events of this component.
|
void |
setDragAcceptAngle(float degree) |
Sets the deflection angle for a horizontal or vertical drag recognizer.
|
void |
setDraggedListener(int dragMode,
Component.DraggedListener listener) |
Registers a listener for drag events of a component.
|
void |
setEditEventListener(Component.EditEventListener listener) |
Registers a listener to observe editing events that are triggered by keyboard shortcuts and
distributed to this component.
|
void |
setEnabled(boolean enabled) |
Sets the enabled state of the component.
|
protected void |
setEstimatedSize(int estimatedWidth,
int estimatedHeight) |
This should be called from
EstimateSizeListener#onEstimateSize(int, int) to set the measured width and height. |
protected void |
setEstimateSizeListener(Component.EstimateSizeListener listener) |
Adds a listener on component's size estimating process.
|
void |
setFadeEffectBoundaryWidth(int width) |
Sets the boundary width for the component's fade-effect area.
|
void |
setFadeEffectColor(Color color) |
Sets the color displayed when producing the fade effect.
|
void |
setFocusable(int focusable) |
Sets whether the component can receive focus.
|
void |
setFocusBorderEnable(boolean enabled) |
Sets whether to enable the focus border when this component is in focus.
|
void |
setFocusBorderPadding(int padding) |
Sets the padding between the focus border and this component.
|
void |
setFocusBorderRadius(float radius) |
Sets the radius for the focus border.
|
void |
setFocusBorderRadius(float[] radii) |
Sets the radii for corners of the focus border.
|
void |
setFocusBorderWidth(int width) |
Sets the width for the focus border.
|
void |
setFocusChangedListener(Component.FocusChangedListener listener) |
Registers a listener for focus change events in the component.
|
void |
setFocusedEffect(boolean enabled) |
Sets whether this component has a focus effect when it gains focus.
|
void |
setForeground(Element element) |
Sets a specified element as the foreground of the component.
|
void |
setForegroundGravity(int foregroundGravity) |
已过时。
This change is effective since API version 6. This method is redundant and is therefore deprecated.
|
void |
setForwardHoverListener(Component.ForwardHoverListener listener) |
Registers a listener to decide forward mouse hover events to children components.
|
void |
setForwardTouchListener(Component.ForwardTouchListener listener) |
Registers a listener to decide forward touch events to children components.
|
void |
setGesturePriority(Component.GestureType gestureType,
int priority) |
Sets the priority of gestures.
|
void |
setHeight(int height) |
Sets the height of a component.
|
void |
setHorizontalPadding(int left,
int right) |
Sets the horizontal padding for this component.
|
void |
setHorizontalPosition(int left,
int right) |
Sets the component's horizontal position relative to the parent container.
|
void |
setHoverEventListener(Component.HoverEventListener listener) |
Registers a listener for hover events in the component.
|
void |
setId(int id) |
Sets the unique ID of the component.
|
void |
setKeyEventListener(Component.KeyEventListener listener) |
Registers a listener for key events in the component.
|
void |
setLayoutConfig(ComponentContainer.LayoutConfig config) |
Sets the layout parameters of a component in its parent layout.
|
void |
setLayoutDirection(Component.LayoutDirection layoutDirection) |
Sets the layout direction for this component.
|
void |
setLayoutRefreshedListener(Component.LayoutRefreshedListener listener) |
Registers a listener for component's relayout.
|
void |
setLeft(int left) |
Sets the left edge position of a component relative to the parent container.
|
void |
setLongClickable(boolean longClickable) |
Sets whether the component is long clickable.
|
void |
setLongClickedListener(Component.LongClickedListener listener) |
Registers a listener for long-click events in the component (the component is clicked and held down).
|
void |
setMarginBottom(int bottom) |
Sets the bottom margin for this component.
|
void |
setMarginLeft(int left) |
Sets the left margin for this component.
|
void |
setMarginRight(int right) |
Sets the right margin for this component.
|
void |
setMarginsLeftAndRight(int left,
int right) |
Sets horizontal margins for this component.
|
void |
setMarginsTopAndBottom(int top,
int bottom) |
Sets vertical margins for this component.
|
void |
setMarginTop(int top) |
Sets the top margin for this component.
|
void |
setMinHeight(int minHeight) |
Sets the minimum height of a component.
|
void |
setMinWidth(int minWidth) |
Sets the minimum possible width of the component.
|
void |
setMode(int mode) |
Sets the showing mode of this component.
|
void |
setMouseEventListener(Component.MouseEventListener listener) |
Registers a listener for mouse events in the component.
|
void |
setMousePointerStyleListener(Component.MousePointerStyleListener listener) |
Registers a listener for mouse pointer style changes.
|
void |
setName(String name) |
Sets the name of the component.
|
void |
setOnDragListener(Component.OnDragListener listener) |
Registers a listener for drag events in the component.
|
void |
setPadding(int left,
int top,
int right,
int bottom) |
Sets the padding of the component.
|
void |
setPaddingBottom(int bottom) |
Sets the bottom padding for this component.
|
void |
setPaddingLeft(int left) |
Sets the left padding for this component.
|
void |
setPaddingRelative(int start,
int top,
int end,
int bottom) |
Sets the relative padding of the component.
|
void |
setPaddingRight(int right) |
Sets the right padding for this component.
|
void |
setPaddingTop(int top) |
Sets the top padding for this component.
|
void |
setPivot(float x,
float y) |
Sets the pivot (point), around which this component is rotated and scaled.
|
void |
setPivot(Point point) |
Sets the pivot (point), around which this component is rotated and scaled based on
point. |
void |
setPivotX(float pivotX) |
Sets the X-axis coordinate of the point around which the component is rotated and scaled, that is, the pivot
point.
|
void |
setPivotY(float pivotY) |
Sets the Y-axis coordinate of the point around which the component is rotated and scaled, that is, the pivot
point.
|
void |
setPosition(int coordX,
int coordY) |
Sets the position of the upper-left corner of a component, relative to the parent layout.
|
void |
setPositionX(int coordX) |
Sets the x-coordinate for the component's upper-left corner relative to the parent layout.
|
void |
setPositionY(int coordY) |
Sets the y-coordinate for the component's upper-left corner relative to the parent layout.
|
void |
setPressState(boolean pressState) |
Sets the pressed state of the component.
|
void |
setRight(int right) |
Sets the right edge position of a component relative to the parent container.
|
void |
setRotation(float degree) |
Sets the degrees that the component is rotated around the Z axis.
|
void |
setRotationEventListener(Component.RotationEventListener listener) |
Registers a listener for rotation events in the component.
|
void |
setRotationSensitivity(float value) |
Sets the rotation sensitivity of a component.
|
void |
setScale(float x,
float y) |
Sets the component's scale factor around the pivot.
|
void |
setScaledListener(Component.ScaledListener listener) |
Registers a listener for scale events of a component.
|
void |
setScaleX(float scaleX) |
Sets the component's scaling factor in the X direction around the pivot point.
|
void |
setScaleY(float scaleY) |
Sets the component's scaling factor in the Y direction around the pivot point.
|
void |
setScrollbarBackgroundColor(Color color) |
Sets the background color of a scroll bar.
|
void |
setScrollbarColor(Color color) |
Sets the color of a scroll bar.
|
void |
setScrollbarFadingDelay(int delay) |
Sets the delay before a scrollbar is fading.
|
void |
setScrollbarFadingDuration(int duration) |
Sets the fading duration of a scrollbar.
|
void |
setScrollbarFadingEnabled(boolean enabled) |
已过时。
This change is effective since API version 6. Replaced by
enableFadeEffect(FadeEffectEnum) or disableFadeEffect(FadeEffectEnum) |
void |
setScrollBarMode(int scrollBarMode) |
Sets the mode of the scrollbar that is being displayed.
|
void |
setScrollbarOverlapEnabled(boolean enabled) |
Sets whether the scroll bar overlaps with the content.
|
void |
setScrollbarRadius(float radius) |
Sets the radius for the scroll bar's rounded border.
|
void |
setScrollbarRoundRect(boolean isRoundRect) |
Sets the shape of the scroll bar.
|
void |
setScrollbarStartAngle(float start) |
Sets the start angle for a rounded scroll bar.
|
void |
setScrollbarSweepAngle(float sweep) |
Sets the sweep angle for a rounded scroll bar.
|
void |
setScrollbarThickness(int thickness) |
Sets the thickness of a scroll bar.
|
void |
setScrolledListener(Component.ScrolledListener listener) |
Registers a listener for scroll events in the component.
|
void |
setSelected(boolean selected) |
Sets the selection state of the component.
|
void |
setShadowColor(Color color) |
Sets the shadow's color of
Component. |
void |
setShadowStyle(Component.ShadowSize size,
Component.ShadowMode mode,
Component.ShadowDevice device) |
Sets a specified element as the shadow style of the component.
|
void |
setSoundEnable(boolean enable) |
Enables or disables the sound for this component when it is being clicked.
|
void |
setSpeechEventListener(Component.SpeechEventListener listener) |
Sets a listener for voice events in this component.
|
void |
setTag(Object tag) |
Sets the tag associated with a component.
|
void |
setTop(int top) |
Sets the top edge position of a component relative to the parent container.
|
void |
setTouchEventListener(Component.TouchEventListener listener) |
Registers a listener for touch events in the component.
|
void |
setTouchFocusable(boolean focusable) |
Sets whether the component can receive focus while in touch mode.
|
void |
setTransitionSymbol(String symbol) |
Sets transition symbol.
|
void |
setTranslation(float x,
float y) |
Sets the component's horizontal translation relative to its left boundary and the vertical translation relative
to its top boundary.
|
void |
setTranslationX(float translationX) |
Sets the horizontal position of the component relative to its left position.
|
void |
setTranslationY(float translationY) |
Sets the vertical position of the component relative to its top position.
|
void |
setTranslationZ(float translationZ) |
Sets the depth location change of this component in the direction perpendicular to the screen.
|
void |
setUnconsumedKeyEventListener(Component.UnconsumedKeyEventListener listener) |
Registers a listener for unconsumed key events in the component.
|
void |
setUserNextFocus(int side,
int id) |
Sets the next component to give focus to.
|
void |
setVerticalPadding(int top,
int bottom) |
Sets the vertical padding for this component.
|
void |
setVerticalPosition(int top,
int bottom) |
Sets the component's vertical position relative to the parent container.
|
void |
setVibrationEffectEnabled(boolean enabled) |
Sets whether the vibration effect is enabled.
|
void |
setVisibility(int visibility) |
Sets the visibility of a component.
|
void |
setWidth(int width) |
Sets the width of a component.
|
void |
showFocusBorder() |
已过时。
This change is effective since API version 8. This method is redundant and temporary and is
therefore deprecated.
|
boolean |
simulateClick() |
Performs a click event in a component.
|
boolean |
simulateDrag() |
Performs a drag event of a component.
|
boolean |
startDragAndDrop(MimeData data,
Component.DragFeedbackProvider shadowProvider) |
Starts dragging a component.
|
void |
subscribeVoiceEvents(Component.VoiceEvent voiceEvent) |
Subscribes to a specified voice event of this component.
|
void |
unsubscribeVoiceEvents() |
Unsubscribes from all voice events subscribed to by the current component at a time.
|
public static final int ACCESSIBILITY_ADAPTABLE
public static final int ACCESSIBILITY_DISABLE
public static final int ACCESSIBILITY_ENABLE
public static final int AXIS_X
public static final int AXIS_Y
public static final Component.ContourRefreshedListener CONTOUR_BACKGROUND
public static final Component.ContourRefreshedListener CONTOUR_BORDER
public static final Component.ContourRefreshedListener CONTOUR_PADDING_BORDER
public static final float DEFAULT_SCALE
public static final int DRAG_DOWN
public static final int DRAG_HORIZONTAL
public static final int DRAG_HORIZONTAL_VERTICAL
public static final int DRAG_LEFT
public static final int DRAG_RIGHT
public static final int DRAG_UP
public static final int DRAG_VERTICAL
public static final int EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED
public static final int EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR
public static final int EVENT_TYPE_COMPONENT_CLICKED
public static final int EVENT_TYPE_COMPONENT_FOCUSED
public static final int EVENT_TYPE_COMPONENT_LONG_CLICKED
public static final int EVENT_TYPE_COMPONENT_SCROLLED
public static final int EVENT_TYPE_COMPONENT_SELECTED
public static final int EVENT_TYPE_COMPONENT_TEXT_UPDATE
public static final int EVENT_TYPE_NOTICE
public static final int EVENT_TYPE_NOTIFICATION_STATE_UPDATE
public static final int EVENT_TYPE_TOAST_SHOW
public static final int EVENT_TYPE_WINDOW_STATE_UPDATE
public static final int FOCUS_ADAPTABLE
setFocusable(int).public static final int FOCUS_DISABLE
setFocusable(int).public static final int FOCUS_ENABLE
setFocusable(int).public static final int FOCUS_NEXT
findNextFocusableComponent(int).public static final int FOCUS_PREVIOUS
findNextFocusableComponent(int).public static final int FOCUS_SIDE_BOTTOM
findNextFocusableComponent(int).public static final int FOCUS_SIDE_LEFT
findNextFocusableComponent(int).public static final int FOCUS_SIDE_RIGHT
findNextFocusableComponent(int).public static final int FOCUS_SIDE_TOP
findNextFocusableComponent(int).public static final int HIDE
setVisibility(int).public static final int HORIZONTAL
public static final int ID_DEFAULT
-1 indicates that the component ID is not set.public static final int INHERITED_MODE
setMode(int).public static final int INVISIBLE
setVisibility(int).public static final int OVAL_MODE
setMode(int).public static final int OVAL_SCROLL_BAR_MODE
setScrollBarMode(int).protected static final int POSITION_X_INDEX
protected static final int POSITION_Y_INDEX
public static final int RECT_MODE
setMode(int).public static final int RECT_SCROLL_BAR_MODE
setScrollBarMode(int).public static final int SCROLL_AUTO_STAGE
public static final int SCROLL_IDLE_STAGE
public static final int SCROLL_NORMAL_STAGE
public static final int UNSPECIFIED_SCROLL_BAR_MODE
setScrollBarMode(int).public static final int VERTICAL
public static final int VISIBLE
setVisibility(int).protected Element mBackgroundElement
protected Canvas mCanvasForTaskOverContent
protected Canvas mCanvasForTaskUnderContent
protected ComponentParent mComponentParent
protected Context mContext
protected Component.DrawTask mDrawTaskOverContent
protected Component.DrawTask mDrawTaskUnderContent
protected Component.EstimateSizeListener mEstimateSizeListener
protected Element mForegroundElement
protected Component.ForwardHoverListener mForwardHoverListener
protected Component.HoverEventListener mHoverEventListener
protected Component.KeyEventListener mKeyEventListener
protected Component.MouseEventListener mMouseEventListener
protected float[] mPosition
protected Component.RotationEventListener mRotationEventListener
protected ShadowElement mShadowElement
protected Component.UnconsumedKeyEventListener mUnconsumedKeyEventListener
public Component(Context context)
Component instance by using the default attribute set and style.context - Indicates the application context.public Component(Context context, AttrSet attrSet)
Component instance by using specified attribute set and default style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public Component(Context context, AttrSet attrSet, String styleName)
Component instance by using specified attribute set and specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public Component(Context context, AttrSet attrSet, int resId)
Component instance based on the context, attribute set, and
default theme after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set.resId - Indicates the resource ID of the default theme.public ComponentHolder findComponentHolderById(int resId)
ComponentHolder instance using the resource ID.resId - Indicates the resource ID to use.ComponentHolder instance.public void draw(Canvas canvas)
This method must be called in the main thread.
canvas - Indicates the canvas used for drawing.public final boolean startDragAndDrop(MimeData data, Component.DragFeedbackProvider shadowProvider)
There is one way to turn on dragging. LongClickedListener need to be set for this component.
After LongClickedListener listener is invoked before TouchEvent#PRIMARY_POINT_UP,
component is ready for DragAndDrop.
startDragAndDrop need to be invoked in LongClickedListener#onLongClicked callback
with created DragFeedbackProvider and shadowComponent.
data - Indicates the data carried by the dragged component.shadowProvider - Indicates the provider of the dragged component's style.true if the component is ready for dragging; returns false otherwise.public final ComponentParent getComponentParent()
Each component must be within a parent layout, or itself must be a root component (or layout).
protected void setEstimateSizeListener(Component.EstimateSizeListener listener)
listener - Specifies the size estimating listener for a component.Component.EstimateSizeListenerpublic void addDrawTask(Component.DrawTask task)
This method invokes addDrawTask(ohos.agp.components.Component.DrawTask,int), where the value of layer is
DrawTask#BETWEEN_CONTENT_AND_FOREGROUND.
task - Indicates the drawing task to add.addDrawTask(DrawTask, int),
invalidate()public void addDrawTask(Component.DrawTask task, int layer)
The drawing of each component includes its foreground, content, and background.You can use this method to add a drawing task between the foreground and the content or between the content and the background.
task - Indicates the drawing task to add.layer - Indicates the position of the drawing task. This value can only be
DrawTask#BETWEEN_BACKGROUND_AND_CONTENT or DrawTask#BETWEEN_CONTENT_AND_FOREGROUND.public void invalidate()
This method is mainly used to update a component's drawing tasks. Modifying component attributes will automatically trigger a component update.
public void setContentEnable(boolean enable)
enable - Indicates whether to draw the content for a component. true means to draw the component content;
false means not to.public boolean getContentEnable()
true if the component will be drawn; returns false otherwise.
The default value is true.public void setFocusedEffect(boolean enabled)
By default, the focus effect of a component is a focus border. A component may have its own custom focus effect. For example, the custom focus effect of a button can be a focus border with rounded corners. You can also set the background or foreground to achieve the focus effect.
enabled - Specifies whether to enable the focus effect. The value true (default value) means
to enable the focus effect, and false means the opposite.public boolean hasFocusedEffect()
true (default value) if a focus effect is displayed;
returns false otherwise.public AnimatorProperty createAnimatorProperty()
When you use this method to create an animator object, the current component is automatically set as the target of the animator. The animator only changes the display of the component and the event capturing area. It does not change the layout of the component.
public Context getContext()
public void setPosition(int coordX,
int coordY)
coordX - Indicates the x-axis position, in pixels.coordY - Indicates the y-axis position, in pixels.public void setPositionX(int coordX)
coordX - Indicates the x-coordinate to set, in pixels.public void setPositionY(int coordY)
coordY - Indicates the y-coordinate to set, in pixels.public void setContentPosition(float x,
float y)
The position of each component relative to the parent layout is indicated using the position of its upper-left corner. This method is used to change the position of a component in the parent layout, as well as the area where the component listens for screen events. This method does not change the layout. It should be used mainly for animation.
x - Indicates the new X-axis coordinate, in unit of pixels.y - Indicates the new Y-axis coordinate, in unit of pixels.public void setContentPositionX(float x)
You can use this method to:
Calling this method does not change the layout. It should be used mainly for animations.
x - Indicates the x-coordinate to set, in pixels.public void setContentPositionY(float y)
You can use this method to:
Calling this method does not change the layout. It should be used mainly for animations.
y - Indicates the y-coordinate to set, in pixels.public float getContentPositionX()
The position of each component relative to the parent layout is indicated using the position of its upper-left corner. This value is not the same as the absolute position of the component's left edge.
public float getContentPositionY()
The position of each component relative to the parent layout is indicated using the position of its upper-left corner. This value is not the same as the absolute position of the component's top edge.
public float[] getContentPosition()
The position of each component relative to the parent layout is indicated using the position of its upper-left corner. These values are not the same as the absolute position of the component's upper-left corner.
public int[] getLocationOnScreen()
public void setWidth(int width)
This method modifies the width in the LayoutConfig object associated with the component.The actual
effect varies depending on the parent layout type.
width - Indicates the width of the component, in unit of pixels. A value less than 0 means
that the component will not be displayed.public void setComponentSize(int width,
int height)
width - Indicates the component width to set, in pixels. If the value is less than 0, the component
is not displayed.height - Indicates the component height, in pixels. If the value is less than 0, the component is
not displayed.public DimensFloat getComponentSize()
DimensFloat representing the component size, in pixels.public int getWidth()
This method obtains the actual width of the component if it is already bound to a window.
Formula: Width = Location of the right edge - Location of the left edge. If the component is not bound to a
window, this method returns its width recorded in LayoutConfig.
public void setHeight(int height)
This method modifies the height in the LayoutConfig object associated with the component. The
actual effect varies depending on the parent layout type.
height - Indicates the height of the component, in unit of pixels. A value less than 0 means
that the component will not be displayed.public void setRotationSensitivity(float value)
ROTATION_SENSITIVITY_LOW and ROTATION_SENSITIVITY_HIGH.
The rotation sensitivity of ROTATION_SENSITIVITY_DEFAULT is set by default for each component. You can
also adjust the rotation sensitivity appropriately.value - Indicates the rotation sensitivity of the component.public float getRotationSensitivity()
public int getHeight()
This method obtains the actual height of the component if it is already bound to a window. Formula: Height =
Location of the top edge - Location of the bottom edge. If the component is not bound to a window, this method
returns its height recorded in LayoutConfig.
public int getLeft()
This value is the left edge position of the actual layout. It is different from the left edge of the component's displayed area.
public void setLeft(int left)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.
left - Indicates the left edge's relative position, in pixels.public int getRight()
This value is the right edge position of the actual layout. It is different from the right edge of the component's displayed area.
public void setRight(int right)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.
right - Indicates the right edge's relative position, in pixels.public int getTop()
This value is the top edge position of the actual layout. It is different from the top edge of the component's displayed area.
public void setTop(int top)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.*
top - Indicates the top edge's relative position, in pixels.public int getBottom()
This value is the bottom edge position of the actual layout. It is different from the bottom edge of the component's displayed area.
public void setBottom(int bottom)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.
bottom - Indicates the bottom edge's relative position, in pixels.public void setComponentPosition(int left,
int top,
int right,
int bottom)
This method can be used only by the layout system. We can't use it generally because the property values can be changed at any time by the parent container.
left - Indicates the position of the component's left edge, in pixels.top - Indicates the position of the component's top edge, in pixels.right - Indicates the position of the component's right edge, in pixels.bottom - Indicates the position of the component's bottom edge, in pixels.IllegalArgumentException - Throws this exception if the width (right - left) or height (bottom - top)
value is less than 0.public void setComponentPosition(Rect rect)
rect.
This method can be used only by the layout system. We can't use it generally because the property values can be changed at any time by the parent container.
rect - Indicates the position to set.IllegalArgumentException - Throws this exception if the width (right - left) or height (bottom - top)
value is less than 0 or rect argument value is null.public void setHorizontalPosition(int left,
int right)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.
left - Indicates the position of the component's left edge, in pixels.right - Indicates the position of the component's right edge, in pixels.IllegalArgumentException - Throws this exception if the width (right - left)
value is less than 0.public void setVerticalPosition(int top,
int bottom)
This method can be used only by the layout system. We can't use it generally because the property value can be changed at any time by the parent container.
top - Indicates the position of the component's top edge, in pixels.bottom - Indicates the position of the component's bottom edge, in pixels.IllegalArgumentException - Throws this exception if the height (bottom - top)
value is less than 0.public int[] getHorizontalPosition()
public int[] getVerticalPosition()
public Rect getComponentPosition()
Rect representing the position of the component, in pixels.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 getMarginLeft()
public int getMarginTop()
public int getMarginRight()
public int getMarginBottom()
public int[] getMargins()
public int[] getMarginsLeftAndRight()
public int[] getMarginsTopAndBottom()
@Deprecated public void setForegroundGravity(int foregroundGravity)
foregroundGravity - Indicates the foreground position of the component.@Deprecated public int getForegroundGravity()
setForegroundGravity(int)public void setLayoutConfig(ComponentContainer.LayoutConfig config)
The child class of layout parameters passed in varies depending on the child class of the parent layout.
After the component tree that contains the current component is added to a window, the system calculates the
position,
width, and height of the component in the parent layout based on the ComponentContainer.LayoutConfig
parameters and
type of the component.
The following child classes of layout parameters are supported:
config - Indicates the layout parameters of the component. These parameters cannot be null.public ComponentContainer.LayoutConfig getLayoutConfig()
All components should have layout parameters. They supply parameters to the parent layout of a component
specify how the component should be arranged.
There are many child classes of ComponentContainer.LayoutConfig, which correspond to different child
classes of ComponentContainer that are responsible for arranging their children.
If the component is not bound to a parent ComponentContainer or an exception occurs when calling
the component is bound to a parent ComponentContainer, this method must not return null.
null if the component is not
bound to a parent ComponentContainer or an exception occurs when callingpublic void setMinHeight(int minHeight)
There is no guarantee that a component will be able to reach this minimum height, for example, if the parent layout does not support this minimum height.
minHeight - Indicates the minimum possible height of the component, in pixels.getMinHeight()public int getMinHeight()
The component may not be able to achieve this minimum height.
setMinHeight(int)public void setMinWidth(int minWidth)
There is no guarantee that the component will be able to reach this minimum width, for example, if the parent layout does not support this minimum width.
minWidth - Indicates the minimum possible width of the component, in pixels.getMinWidth()public int getMinWidth()
The component may not be able to achieve this minimum width.
setMinWidth(int)public void setComponentMinSize(int minWidth,
int minHeight)
minWidth - Indicates the minimum possible width to set, in pixels.minHeight - Indicates the minimum possible height to set, in pixels.public DimensFloat getComponentMinSize()
DimensFloat object representing the possible minimum size, in pixels.public int getScrollValue(int direction)
public void setVisibility(int visibility)
When the parameter value is VISIBLE, the component occupies space and needs to be rendered.
When the parameter value is INVISIBLE, the component occupies space but does not need to be rendered.
When the parameter value is HIDE, the component occupies no space and does not need to be rendered.
public int getVisibility()
A component can have three visibility states:
VISIBLE,
INVISIBLE, or HIDE.setVisibility(int visibility)public void release()
public void announceAccessibility(String text)
TYPE_ANNOUNCEMENT type.text - Indicates the text to set.public void setAccessibilityDescription(String description)
description - Indicates the accessibility description to set.public String getAccessibilityDescription()
public void notifyAccessibility(int eventType)
eventType - Indicates the accessibility event to trigger. The value can be any of the following:
public void setAccessibility(int flag)
flag - Indicates accessibility state to set, which can be ACCESSIBILITY_DISABLE,
ACCESSIBILITY_AUTO, or ACCESSIBILITY_ENABLE.public int getAccessibility()
public boolean isBoundToWindow()
Each window creates a component tree. Each component that needs to be displayed in the window must be bound to this tree.Adding a component to the component tree is equivalent to binding a component to a window.
true if the component has been bound to a window; returns false otherwise.public boolean isComponentDisplayed()
This is different from the visibility of the component.
For example, for a component whose visibility state is VISIBLE, if its size is 0 or if its parent layout
cannot be displayed, the component still cannot be displayed on the screen.
On the contrary, even for a component that is completely transparent, this method returns true if the
component
can be displayed on the screen simply by changing its transparency color.
true if the component can be displayed; returns false otherwise.public void setComponentStateChangedListener(Component.ComponentStateChangedListener listener)
listener - Indicates the listener for state change events of the component.public Component.ComponentStateChangedListener getComponentStateChangedListener()
public void setClickedListener(Component.ClickedListener listener)
When the position of a click is within the component's display area, a click event is triggered, and all registered observers are notified.
listener - Indicates the listener for click events.public Component.ClickedListener getClickedListener()
public void setEditEventListener(Component.EditEventListener listener)
listener - Indicates the listener to register.public Component.EditEventListener getEditEventListener()
public void setDoubleClickedListener(Component.DoubleClickedListener listener)
When a double-click event occurs in the display area of this component, this method is called and all registered observers are notified.
listener - Indicates the listener to register.public void setScaledListener(Component.ScaledListener listener)
All registered observers will be notified of scale events dispatched to this component.
listener - Indicates the scale listener.public Component.ScaledListener getScaledListener()
public void setGesturePriority(Component.GestureType gestureType, int priority)
gestureType - Gesture type GestureType.priority - Priority of the gesture. Larger value indicates a higher priority, and the default priority is 0.public int getGesturePriority(Component.GestureType gestureType)
gestureType - Gesture type GestureType.public void setOnDragListener(Component.OnDragListener listener)
When the position of a dragging action is within the component's display area, a drag event is triggered, and all registered observers are notified.
listener - Indicates the listener for drag events.public void setDraggedListener(int dragMode,
Component.DraggedListener listener)
All registered observers will be notified of drag events dispatched to this component. If listener is null, drag events will be canceled. One component can own several identical drag recognizers, and the user-defined drag recognizer takes precedence over the internal drag recognizer.
dragMode - Indicates the current drag mode. The value can be one of the following:
DRAG_HORIZONTAL_VERTICAL, DRAG_HORIZONTAL, DRAG_VERTICALlistener - Indicates the listener for drag events.public Component.DraggedListener getDraggedListener()
public void setDragAcceptAngle(float degree)
The deflection angle refers to the included angle between the dragging direction and the principal direction,
which is horizontal regarding a horizontal drag recognizer or vertical regarding a vertical drag recognizer.
If the dragging displacement on the touchscreen projected onto the principal direction
exceeds the preset threshold (8 vp) but is less than twice the threshold,
the drag recognizer calculates the deflection angle
and assumes that dragging starts only when the calculated angle is less than the one you set via this method.
If the dragging displacement exceeds twice the threshold, the drag recognizer assumes that dragging starts,
regardless of the deflection angle you set.
This method takes effect only on a drag recognizer whose dragMode is set to
DRAG_HORIZONTAL or DRAG_VERTICAL via setDraggedListener(int, ohos.agp.components.Component.DraggedListener).
The default deflection angle is 26.57 degrees.
degree - Indicates the deflection angle to set. The value ranges from 15.0 to 75.0 degrees.getDragAcceptAngle(),
setDraggedListener(int dragMode, DraggedListener listener)public float getDragAcceptAngle()
setDragAcceptAngle(float degree)public boolean onDrag(Component component, DragEvent event)
component - Indicates the component.event - Indicates the drag event.true if the drag event is processed correctly; returns false otherwise.public void setFocusChangedListener(Component.FocusChangedListener listener)
All registered observers will be notified of focus change events dispatched to the component.
listener - Indicates the listener for focus change events.public void setKeyEventListener(Component.KeyEventListener listener)
All registered observers will be notified of key events dispatched to the component.
listener - Indicates the listener for key events.public void setUnconsumedKeyEventListener(Component.UnconsumedKeyEventListener listener)
All registered observers will be notified of unconsumed key events dispatched to the component.
listener - Indicates the listener for key events.public void setMouseEventListener(Component.MouseEventListener listener)
All registered observers will be notified of mouse events dispatched to the component.
listener - Indicates the listener for mouse events.public Component.MouseEventListener getMouseEventListener()
public void setForwardHoverListener(Component.ForwardHoverListener listener)
listener - Indicates the listener to forward mouse hover events.public Component.ForwardHoverListener getForwardHoverListener()
public void setHoverEventListener(Component.HoverEventListener listener)
All registered observers will be notified of hover events dispatched to the component.
listener - Indicates the listener for hover events.public Component.HoverEventListener getHoverEventListener()
public void setMousePointerStyleListener(Component.MousePointerStyleListener listener)
listener - Indicates the listener to register.public Component.MousePointerStyleListener getMousePointerStyleListener()
public Component.KeyEventListener getKeyEventListener()
public void setRotationEventListener(Component.RotationEventListener listener)
All registered observers will be notified of rotation events dispatched to the component.
listener - Indicates the listener for rotation events.public Component.RotationEventListener getRotationEventListener()
public void setLongClickedListener(Component.LongClickedListener listener)
All registered observers will be notified of long-click events dispatched to the component.
listener - Indicates the listener for long-click events.public void setTouchEventListener(Component.TouchEventListener listener)
All registered observers will be notified of touch events dispatched to the component.
listener - Indicates the listener for touch events.public void setForwardTouchListener(Component.ForwardTouchListener listener)
listener - Indicates the listener to forward touch events.public Component.ForwardTouchListener getForwardTouchListener()
public Component.TouchEventListener getTouchEventListener()
public void requestForceForwardTouchEvent(boolean forceForward)
forceForward - True if the child want the parent to keep forwarding touch event, false otherwisepublic void setLayoutRefreshedListener(Component.LayoutRefreshedListener listener)
listener - Indicates the listener for component relayout.public Component.LayoutRefreshedListener getLayoutRefreshedListener()
public void setContourRefreshedListener(Component.ContourRefreshedListener listener)
Contour object of a component.listener - Indicates the listener for contour updates.public Component.ContourRefreshedListener getContourRefreshedListener()
Contour object of a component.null otherwise.public void setContour(Contour contour)
Contour object for the component.contour - Indicates the custom Contour object.public Contour getContour()
Contour object of the current component.Contour object of the current component.public void setClipToContourEnabled(boolean enable)
Contour object of a component can be used for content clipping. Clipping is supported
only when the Contour object takes the form of a right-angled rectangle, a rounded rectangle, or a
circle. The part beyond the Contour object will be cropped.enable - Indicates whether clipping is supported. Value true indicates that clipping is supported;
value false indicates the opposite.public boolean isClipToContourEnabled()
Contour object of a component can be used for content clipping.true if the Contour object can be used for content clipping;
returns false otherwise.public void refreshContour()
Contour object of a component and triggers
ContourRefreshedListener#onContourRefreshed(Component) for setting a custom Contour object.
Use this method if you want to actively update the Contour object of a component.public void setScrolledListener(Component.ScrolledListener listener)
All registered observers will be notified of scroll events dispatched to the component.
listener - Indicates the listener for scroll events.public void addScrolledListener(Component.ScrolledListener listener)
A registered listener will receive a notification when the component reports a scrolling event.
listener - Indicates the listener for scrolling events.public void removeScrolledListener(Component.ScrolledListener listener)
listener - Indicates the listener for scrolling events.public boolean canScroll(int orientation)
orientation - Indicates the dragging direction. The value can be DRAG_UP, DRAG_DOWN,
DRAG_LEFT, or DRAG_RIGHT.true if the component can be scrolled in the specified direction; returns false
otherwise.public int getScrollState()
public void setCanAcceptScrollListener(Component.CanAcceptScrollListener listener)
public boolean simulateClick()
This method calls the OnClickListener created for the component. The observer registered by the
setClickedListener(ohos.agp.components.Component.ClickedListener) method will be notified. After the callback is executed,
the system passes a lifting event to the click event listener.
true if the callback function is executed successfully.public boolean performScale()
This method invokes the callback for scale events of the control. Observers registered by the
setScaledListener(ohos.agp.components.Component.ScaledListener) method will be notified. When the callback is executed,
the system will transfer the scale event to the scale listener.
true if the callback function is executed successfully.public boolean simulateDrag()
This method invokes the callback for drag events of the control. Observers registered by the
setDraggedListener(int,ohos.agp.components.Component.DraggedListener) method will be notified. When the callback is
executed, the system will transfer the drag event to the drag listener.
true if the callback function is executed successfully.public boolean callOnClick()
Unlike simulateClick(), this method only notifies observers registered using the
setClickedListener(ohos.agp.components.Component.ClickedListener) method, but does not perform any actual operation on the
component itself.
true if the assigned OnClickListener is called successfully.public boolean executeLongClick()
This method calls the OnLongClickListener created for the component. Observers registered by the
setLongClickedListener(ohos.agp.components.Component.LongClickedListener) method will be notified. After the callback is
executed, the system passes a lifting event to the long-click event listener.
true if the callback function is executed successfully.public boolean executeDoubleClick()
This method calls the OnDoubleClickListener created for this component.
Observers registered by the setDoubleClickedListener(ohos.agp.components.Component.DoubleClickedListener) method will be notified.
After the callback is invoked, the system passes an event indicating the end of a double-click event to the
listener set by setDoubleClickedListener(ohos.agp.components.Component.DoubleClickedListener).
true if the operation is successful; returns false otherwise.public void setClickable(boolean clickable)
If a component is clickable, its state will change to pressed upon every click. Child classes should set the component to clickable to visually react to user clicks. If a component is not clickable, it should not be able to receive focus. If it has already received focus, the focus should be cleared immediately.
clickable - true means to make the component clickable, and false means the opposite.isClickable()public boolean isClickable()
If a component is not clickable, it cannot receive focus.
true if the component is clickable; returns false if it is not.setClickable(boolean)public void setEnabled(boolean enabled)
The interpretation of the enabled state varies depending on the child class. If a component is not enabled, it should not acquire focus.
enabled - true means the component is enabled, and false means the opposite.public void setClipEnabled(boolean enabled)
enabled - true means to allow auto-clipping, and false means the opposite.public boolean getClipEnabled()
true if automatic clipping is enabled; returns false otherwise.public boolean isEnabled()
true if the component is enabled; returns false if it is not.public void setFocusable(int focusable)
The value FOCUS_ENABLE means the component can receive focus.
The value FOCUS_ADAPTABLE means to let the framework to determine whether the component can receive
focus based on the component's interactivity. This is the default value. The value FOCUS_DISABLE
ensures that the component is also not focusable in touch mode.
Each component uses a state bit to indicate whether it is focusable. If a component is not clickable, this
state bit
cannot be changed to indicate focusable.
focusable - Indicates whether the component can gain focus. The value can be FOCUS_DISABLE,
FOCUS_ENABLE, or FOCUS_ADAPTABLE.@Deprecated public void showFocusBorder()
@Deprecated public void hideFocusBorder()
public void setTouchFocusable(boolean focusable)
Setting this to true will also ensure that the component is focusable.
focusable - Indicates whether the component can receive focus.public int getFocusable()
The return value is the same as the value set by the setFocusable(int) method.
FOCUS_DISABLE, FOCUS_ENABLE, or FOCUS_ADAPTABLE.public void setId(int id)
The component ID is usually a non-negative value, and is set to -1 by default.
id - Indicates the component ID to set.public int getId()
The default value is -1.
public void setName(String name)
The component name is usually a string, and is set to empty by default.
name - Indicates the component name to set.public String getName()
The default name is empty.
public void setLongClickable(boolean longClickable)
A long-clickable component reacts to long click events, that is, the user holding down a button for a longer duration than a tap.
longClickable - Indicates whether the component is long clickable.isLongClickOn()public boolean isLongClickOn()
A long-clickable component reacts to long click events, that is, the user holding down a button for a longer duration than a tap.
true if the component is long clickable; returns false otherwise.setLongClickable(boolean)public void playSound(int soundId)
soundId - Indicates the type of the sound to play, which can be 0 for SOUND_CLICK,
1 for SOUND_UP, 2 for SOUND_DOWN, 3 for SOUND_LEFT, or 4 for SOUND_RIGHT.public void setSoundEnable(boolean enable)
enable - Specifies whether to enable the sound for the component. The value true means to
enable the sound, and false means the opposite.public boolean isSoundEnable()
true if the sound is played; returns false otherwise.public void setPadding(int left,
int top,
int right,
int bottom)
A component reserves the spaces for the paddings on all four sizes before drawing itself.
left - Indicates the left padding in pixels.top - Indicates the top padding in pixels.right - Indicates the right padding in pixels.bottom - Indicates the bottom padding in pixels.public void setPaddingRelative(int start,
int top,
int end,
int bottom)
At present, it is the same as setPadding(int,int,int,int).
start - Indicates the start padding in pixels.top - Indicates the top padding in pixels.end - Indicates the end padding in pixels.bottom - Indicates the bottom padding in pixels.public int getPaddingBottom()
public int getPaddingEnd()
public int getPaddingLeft()
public int getPaddingRight()
public int getPaddingStart()
public int getPaddingTop()
public void setPaddingTop(int top)
top - Indicates the top padding to set, in pixels.public void setPaddingBottom(int bottom)
bottom - Indicates the bottom padding to set, in pixels.public void setPaddingLeft(int left)
left - Indicates the left padding to set, in pixels.public void setPaddingRight(int right)
right - Indicates the right padding to set, in pixels.public void setHorizontalPadding(int left,
int right)
left - Indicates the left padding to set, in pixels.right - Indicates the right padding to set, in pixels.public void setVerticalPadding(int top,
int bottom)
top - Indicates the top padding to set, in pixels.bottom - Indicates the bottom padding to set, in pixels.public int[] getPadding()
public int[] getHorizontalPadding()
public int[] getVerticalPadding()
public void setPressState(boolean pressState)
Calling this method may change the appearance of the component, if a different appearance has been set for such state.
pressState - Indicates the pressed state. true means to set the component's internal state to
pressed.isClickable(),
setClickable(boolean)public boolean isPressed()
If the setPressState(boolean) function has not been invoked, only a clickable component can enter the
pressed state.
true if the component is in pressed state; returns false otherwise.public void setSelected(boolean selected)
A component can be selected or deselected.
Note that being selected is not the same as in focus.
components are typically selected in the context of an AdapterComponent like
ListContainer; a selected component is highlighted.
selected - Indicates the selected state of the component. true indicates the component is selected.public boolean isSelected()
true if the component is selected; returns false otherwise.public boolean hasFocus()
true if the component or its parent component has focus; returns false otherwise.public boolean isFocusable()
true if the component can receive focus; returns false otherwise.public boolean isTouchFocusable()
true if the component can receive focus in touch mode; returns false otherwise.public boolean isFocused()
true if the component has focus; returns false otherwise.public boolean requestFocus()
A component will not be able to actually take focus in any of the following situations:
the component is not focusable (isFocusable() returns false); or the component is not focusable
in touch mode (isTouchFocusable() returns false); or the component is invisible,
disabled, or has not acquired space for drawing.
true if the component or one of its child components has taken focus; returns
false otherwise.public void clearFocus()
public void postLayout()
public void arrange(int left,
int top,
int width,
int height)
left - Indicates the left edge's relative position, in pixels.top - Indicates the top edge's relative position, in pixels.width - Indicates the component width, in pixels.height - Indicates the component height, in pixels.public void estimateSize(int widthEstimatedConfig,
int heightEstimatedConfig)
widthEstimatedConfig - Horizontal size requirementsheightEstimatedConfig - Vertical size requirementsComponent.EstimateSizeListener.onEstimateSize(int, int)protected final void setEstimatedSize(int estimatedWidth,
int estimatedHeight)
EstimateSizeListener#onEstimateSize(int, int) to set the measured width and height.estimatedWidth - The estimated width of this component.estimatedHeight - The estimated height of this component.public final int getEstimatedWidth()
public final int getEstimatedHeight()
public void setBindStateChangedListener(Component.BindStateChangedListener listener)
To display a component on the screen, you must add it to the component tree of a window.
Each component has a listener list that has implemented the BindStateChangedListener interface. When a
component is bound to or unbound from a window, the
BindStateChangedListener#onComponentBoundToWindow(Component) and
BindStateChangedListener#onComponentUnboundFromWindow(Component) methods of this interface are
called back, respectively.
This method adds listeners specified by the input parameter to the listener list.
listener - Indicates the listener to add.removeBindStateChangedListener(BindStateChangedListener)public void removeBindStateChangedListener(Component.BindStateChangedListener listener)
To display a component on the screen, you must add it to the component tree of a window.
Each component has a listener list that has implemented the BindStateChangedListener interface. When a
component is bound to or unbound from a window, the
BindStateChangedListener#onComponentBoundToWindow(Component) (Component)} and
BindStateChangedListener#onComponentUnboundFromWindow(Component) methods of this interface are
called back, respectively.
This method removes listeners specified by the input parameter from the listener list.
listener - Indicates the listener to remove.setBindStateChangedListener(BindStateChangedListener)public CornerMark bindCornerMark()
null otherwise.enableCornerMark(boolean)public CornerMark getCornerMark()
public void enableCornerMark(boolean enable)
enable - Specifies whether to display the component's corner mark. The value
true indicates that the corner mark is displayed, and false indicates the opposite case.public void setBackground(Element element)
element - Indicates the element to use as the background.public void setForeground(Element element)
element - Indicates the element to use as the foreground.public void setShadowStyle(Component.ShadowSize size, Component.ShadowMode mode, Component.ShadowDevice device)
size - The size we will draw shadow in a round square witch is shadow.mode - The mode we will draw shadow in a round square witch is shadow.device - device The device we will draw shadow in a round square rect witch is shadow.public Element getBackgroundElement()
public Element getForegroundElement()
public void setFocusBorderEnable(boolean enabled)
enabled - Specifies whether the focus border is enabled. The value true indicates that
the focus border is enabled, and the value false (default value) indicates the opposite case.public void setFocusBorderWidth(int width)
The focus border is displayed only when the component is in focus and the focus border is enabled.
width - Indicates the width to set, in pixels. Any value smaller than 0 is invalid.public void setFocusBorderPadding(int padding)
The focus border is displayed only when the component is in focus and the focus border is enabled.
padding - Indicates the padding to set, in pixels. Any value smaller than 0 is invalid.public void setFocusBorderRadius(float radius)
The focus border is displayed only when the component is in focus and the focus border is enabled.
radius - Indicates the radius to set. This value must be greater than 0,
and in this case the focus border is a rounded rectangle or a circle.public void setFocusBorderRadius(float[] radii)
The focus border is displayed only when the component is in focus and the focus border is enabled.
radii - Indicates an array containing radii of the focus border's four corners.
The setting is valid only if the array length is 8. Each pair of values
represents a corner's x-axis radius and the y-axis radius, respectively.public boolean getFocusBorderEnable()
true if the focus border is displayed; returns false (default value) otherwise.public int getFocusBorderWidth()
The focus border is displayed only when the component is in focus and the focus border is enabled.
public int getFocusBorderPadding()
The focus border is displayed only when the component is in focus and the focus border is enabled.
public float[] getFocusBorderRadius()
The focus border is displayed only when the component is in focus and the focus border is enabled.
public void setRotation(float degree)
This method sets the degrees (value range: 0 to 360) that the component rotates around the Z axis relative to its parent layout.
degree - Indicates the degrees that the component is rotated around the Z axis.getRotation()public void setPivotX(float pivotX)
pivotX - Indicates the X-axis coordinate of the pivot point.setPivotY(float),
getPivotX(),
getPivotY()public void setPivotY(float pivotY)
pivotY - Indicates the Y-axis coordinate of the pivot point.setPivotX(float),
getPivotX(),
getPivotY()public void setPivot(float x,
float y)
x - Indicates the x-coordinate of the pivot to set.y - Indicates the y-coordinate of the pivot to set.public void setPivot(Point point)
point.point - Indicates the point to set.public void setScaleX(float scaleX)
scaleX - Indicates the scaling factor in the X direction.setScaleY(float),
getScaleY(),
getScaleX()public void setScaleY(float scaleY)
scaleY - Indicates the scaling factor in the Y direction.setScaleX(float),
getScaleY(),
getScaleX()public void setScale(float x,
float y)
The scale factor is used to control the scale effect of the component based on its original size.
x - Indicates the scale factor in the x-axis direction.y - Indicates the scale factor in the y-axis direction.public void setTranslationX(float translationX)
This value is the distance at which the component has been moved horizontally relative to the getLeft()
position. The rendering position will need to be adjusted accordingly.
translationX - Indicates the horizontal shift of the component relative to its left position, in pixels.setTranslationY(float),
getTranslationX(),
getTranslationY()public void setTranslationY(float translationY)
This value is the distance at which the component has been moved vertically relative to the getTop()
position. The rendering position will need to be adjusted accordingly.
translationY - Indicates the vertical shift of the component relative to its top position, in pixels.setTranslationX(float),
getTranslationX(),
getTranslationY()public void setTranslationZ(float translationZ)
translationZ - Indicates the depth location change of this component.getTranslationZ()public void setTranslation(float x,
float y)
x - Indicates the horizontal translation to set, in pixels.y - Indicates the vertical translation to set, in pixels.public float getRotation()
setRotation(float)public float getPivotX()
This position is relative to the parent layout.
setPivotX(float),
setPivotY(float),
getPivotY()public float getPivotY()
setPivotX(float),
setPivotY(float),
getPivotX()public Point getPivot()
Point representing the pivot.public float getScaleX()
setScaleX(float),
setScaleY(float),
getScaleY()public float getScaleY()
setScaleX(float),
setScaleY(float),
getScaleX()public DimensFloat getScale()
DimensFloat representing the scale factor.public float getTranslationX()
setTranslationX(float),
setTranslationY(float),
getTranslationY()public float getTranslationY()
setTranslationX(float),
setTranslationY(float),
getTranslationX()public float getTranslationZ()
setTranslationZ(float)public DimensFloat getTranslation()
DimensFloat representing the horizontal and vertical translation, in pixels.public void setAltitude(float altitude)
altitude - Indicates the basic depth location of this component.getAltitude()public float getAltitude()
setAltitude(float)public void setShadowColor(Color color)
Component.color - Indicates the color to set.public Color getShadowColor()
Component.public ResourceManager getResourceManager()
public ComponentTreeObserver getComponentTreeObserver()
ComponentTreeObserver for the component.ComponentTreeObserver for the component.public void scrollTo(int x,
int y)
x - Indicates the X-axis coordinate to scroll to.y - Indicates the Y-axis coordinate to scroll to.public void scrollBy(int x,
int y)
x - Indicates the X-axis distance to scroll by.y - Indicates the Y-axis distance to scroll by.public boolean getSelfVisibleRect(Rect rect)
rect - Rect container to save visible Rect valuespublic boolean getVisibleRectOnScreen(Rect rect, int[] position)
Note that the visible area obtained by using this method is the visible area of the current frame.
If you want to obtain the visible area of the next frame, you need to call this method
in LayoutRefreshedListener#onRefreshed(Component).
rect - Indicates the visible rectangle area. When this method returns true, this parameter
saves the visible rectangle area of the component in relative to the upper left corner of the screen.
When this method returns false, the top, bottom, left, and right coordinates of the visible
rectangle are all 0.position - Indicates the position. When this method returns true, this parameter saves the
coordinates of the component in relative to the upper left corner of the screen. When this
method returns false, the coordinates saved in this parameter are all 0.true if the current component has a visible rectangle area on its parent component;
returns false otherwise.public Matrix getMatrix()
public boolean isIdentityMatrix()
true if the current component is an identity matrix; returns false otherwise.public boolean getWindowVisibleRect(Rect visibleRect)
The visible rect of the window can only be obtained by root Component in the slice.
visibleRect - Rect container to save visible rect values of windowpublic void setAlpha(float alpha)
0.0f means the component is completely transparent and 1.0f means the component is completely opaque.
alpha - Indicates the alpha value of the component, ranging from 0.0f to 1.0f.public float getAlpha()
0.0f means the component is completely transparent and 1.0f means the component is
completely opaque.
0.0f to 1.0f.public void setComponentDescription(CharSequence componentDescription)
componentDescription - Indicates the description of the content in the component.public CharSequence getComponentDescription()
public <T extends Component> T findComponentById(int id)
If the ID of the current component itself matches the given ID, the current component is returned. Otherwise,
null is returned.
id - Indicates a unique identifier of a component.null if no component is found.public Component findFocus()
If the component is a simple component and currently has focus, the component is returned. Otherwise,
null is returned.
If the component has descendants and one of the descendants has focus, the focused descendant is returned. If no
descendant has focus, null is returned.
null if no focused component can be found.public Component findNextFocusableComponent(int direction)
The method returns the next focusable component in a given direction from the component that currently has focus. If the next focusable component is not specified, the closest sibling component in the given direction is returned.
direction - Indicates the focus moving direction. The value can be one of the following:
FOCUS_SIDE_LEFT, FOCUS_SIDE_TOP, FOCUS_SIDE_RIGHT,
FOCUS_SIDE_BOTTOM,FOCUS_NEXT, or FOCUS_PREVIOUS.null if no such component can be found.public boolean findRequestNextFocus(int side)
This method finds the next focusable component in a given direction from the currently focused component. If the next focusable component is not found, the closest sibling component in the given direction will be returned.
side - Indicates the focus moving direction. The value can be:
FOCUS_SIDE_LEFT, FOCUS_SIDE_TOP, FOCUS_SIDE_RIGHT,
FOCUS_SIDE_BOTTOM, FOCUS_NEXT, or FOCUS_PREVIOUS.true if the component or one of its child components has gained focus;
returns false otherwise.public void setUserNextFocus(int side,
int id)
The next component to give focus to must be another child of the same parent. Otherwise, a null pointer
will be obtained when findNextFocusableComponent(int) is called.
side - Indicates the focus moving direction. The value can be one of the following:
FOCUS_SIDE_LEFT, FOCUS_SIDE_TOP, FOCUS_SIDE_RIGHT,
FOCUS_SIDE_BOTTOM,FOCUS_NEXT, or FOCUS_PREVIOUS.id - Indicates the ID of the next component to give focus to.public int getUserNextFocus(int side)
side - Indicates the focus moving direction. The value can be one of the following:
FOCUS_SIDE_LEFT, FOCUS_SIDE_TOP, FOCUS_SIDE_RIGHT,
FOCUS_SIDE_BOTTOM,FOCUS_NEXT, or FOCUS_PREVIOUS.-1 if no such component is set.public void subscribeVoiceEvents(Component.VoiceEvent voiceEvent)
voiceEvent - Indicates the voice event.public void unsubscribeVoiceEvents()
public void setSpeechEventListener(Component.SpeechEventListener listener)
listener - Indicates the listener to set for voice events.public Component.SpeechEventListener getSpeechEventListener()
setSpeechEventListener(ohos.agp.components.Component.SpeechEventListener).public void setTag(Object tag)
tag - Indicates the component's tag.getTag()public Object getTag()
setTag(Object)public void enableScrollBar(int direction,
boolean enabled)
direction - Indicates the scroll direction, either AXIS_X for horizontal scroll
or AXIS_Y for vertical scroll.enabled - Specifies whether the scroll bar is enabled. The value true indicates
the scroll bar is enabled, and the value false (default value) indicates the opposite case.isScrollBarOn(int),
(boolean)public boolean isScrollBarOn(int direction)
direction - Indicates the scroll direction, either AXIS_X for horizontal scroll
or AXIS_Y for vertical scroll.true if the scroll bar is enabled; returns false otherwise.enableScrollBar(int, boolean)@Deprecated public void setScrollbarFadingEnabled(boolean enabled)
enableFadeEffect(FadeEffectEnum) or disableFadeEffect(FadeEffectEnum)enabled - Specifies whether to hide scroll bars. true indicates that the scroll bars will be hidden;
false indicates the opposite case.isScrollbarFadingOn(),
enableScrollBar(int, boolean)@Deprecated public boolean isScrollbarFadingOn()
isFadeEffected(FadeEffectEnum)true if scroll bars will fade; returns false otherwise.enableFadeEffect(FadeEffectEnum),
disableFadeEffect(FadeEffectEnum),
setScrollbarFadingDelay(int),
setScrollbarFadingDuration(int)public void enableFadeEffect(Component.FadeEffectEnum fadeEffectEnum)
fadeEffectEnum - Indicates the component indicator to set.public void disableFadeEffect(Component.FadeEffectEnum fadeEffectEnum)
fadeEffectEnum - Indicates the component indicator to set.public boolean isFadeEffected(Component.FadeEffectEnum fadeEffectEnum)
fadeEffectEnum - Indicates the component indicator.true if the fade-out effect is enabled; returns false (default value) otherwise.public void setScrollbarFadingDelay(int delay)
delay - Indicates the delay before the scrollbar is fading, in milliseconds.setScrollbarFadingEnabled(boolean),
getScrollbarFadingDelay()public void setScrollbarRoundRect(boolean isRoundRect)
isRoundRect - Specifies whether the scroll bar is round. The value true
indicates a rounded border, and the value false indicates a rectangular border.public void setScrollbarRadius(float radius)
radius - Indicates the radius to set.public boolean getScrollbarRoundRect()
true if the scroll bar has a rounded border;
returns false if the scroll bar has a rectangular border.public float getScrollbarRadius()
public int getScrollbarFadingDelay()
setScrollbarFadingEnabled(boolean),
setScrollbarFadingDelay(int)public void setScrollbarFadingDuration(int duration)
duration - Indicates the fading duration of the scrollbar, in milliseconds.setScrollbarFadingEnabled(boolean),
getScrollbarFadingDuration()public int getScrollbarFadingDuration()
setScrollbarFadingEnabled(boolean),
setScrollbarFadingDuration(int)public void setScrollbarColor(Color color)
color - Indicates the color of the scroll bar.getScrollbarColor()public Color getScrollbarColor()
setScrollbarColor(Color)public void setScrollbarBackgroundColor(Color color)
color - Indicates the background color of the scroll bar.getScrollbarBackgroundColor()public Color getScrollbarBackgroundColor()
setScrollbarBackgroundColor(Color)public void setScrollbarThickness(int thickness)
thickness - Indicates the thickness of the scroll bar.getScrollbarThickness()public int getScrollbarThickness()
setScrollbarThickness(int)public void setScrollbarStartAngle(float start)
OVAL_MODE is used.start - Indicates the start angle of the rounded scroll bar.getScrollbarStartAngle()public float getScrollbarStartAngle()
OVAL_MODE is used.setScrollbarStartAngle(float)public void setScrollbarSweepAngle(float sweep)
OVAL_MODE is used.sweep - Indicates the sweep angle for a rounded scroll bar.getScrollbarSweepAngle()public float getScrollbarSweepAngle()
OVAL_MODE is used.setScrollbarSweepAngle(float)public void setScrollbarOverlapEnabled(boolean enabled)
enabled - Indicates whether the scroll bar overlaps with the content. true indicates that the
scroll bar overlaps with the content; false indicates otherwise.isScrollbarOverlapEnabled()public void setVibrationEffectEnabled(boolean enabled)
enabled - Indicates whether the vibration effect is enabled.public boolean isVibrationEffectEnabled()
true if vibration effect is enabled; returns false otherwise.public boolean isScrollbarOverlapEnabled()
true if the scroll bar overlaps with the content; returns false otherwise.setScrollbarOverlapEnabled(boolean)public boolean isRtl()
By default, a component is laid out from left to right and from top to bottom.
true if the component is laid out from right to left; and returns false
otherwise.public void setCentralScrollMode(boolean centralMode)
centralMode - Specifies whether to enable the central scroll mode. The default value falseindicates
that the central scroll mode will be disabled, and the value true indicates enabled.public boolean getCentralScrollMode()
public void setMode(int mode)
When the parameter value is INHERITED_MODE (default value), the parent component's showing mode is
used.
When the parameter value is RECT_MODE, the content of this component is displayed in a rectangle.
When the parameter value is OVAL_MODE, the content of this component is displayed in an ellipse.
mode - Indicates the showing mode of this component.getMode(),
getModeResolved()public int getMode()
INHERITED_MODE, RECT_MODE, OVAL_MODEsetMode(int),
getModeResolved()public void setScrollBarMode(int scrollBarMode)
When scrollBarMode is set to UNSPECIFIED_SCROLL_BAR_MODE,
the scrollbar uses the same mode as the showing component.
When this parameter is set to RECT_SCROLL_BAR_MODE, the scrollbar is displayed as a rectangle.
When this parameter is OVAL_SCROLL_BAR_MODE, the scrollbar is displayed as an ellipse.
scrollBarMode - Indicates the mode of the scrollbar to set.getScrollBarMode()public int getScrollBarMode()
UNSPECIFIED_SCROLL_BAR_MODE,
RECT_SCROLL_BAR_MODE, or OVAL_SCROLL_BAR_MODE.setScrollBarMode(int)public int getModeResolved()
RECT_MODE or OVAL_MODE.setMode(int),
getMode()public void setCenterZoomFactor(float scaleX,
float scaleY)
The value can be DEFAULT_SCALE, greater than 1, less than 1, representing the default
zoom factor, zoom-out factor, and zoom-in factor respectively.
scaleX - Indicates the zoom factor for scaling the center component item on X-axis.scaleY - Indicates the zoom factor for scaling the center component item on Y-axis.public float[] getCenterZoomFactor()
public void informConfigurationChanged(Configuration config)
onAttributeConfigChanged(ohos.global.configuration.Configuration).config - Indicates the latest configuration.onAttributeConfigChanged(Configuration)protected void onAttributeConfigChanged(Configuration config)
config - Indicates the latest configuration.informConfigurationChanged(Configuration)public void setLayoutDirection(Component.LayoutDirection layoutDirection)
layoutDirection - Indicates the layout direction to set.Component.LayoutDirection,
getLayoutDirection(),
getLayoutDirectionResolved()public Component.LayoutDirection getLayoutDirection()
LayoutDirection.Component.LayoutDirection,
setLayoutDirection(LayoutDirection),
getLayoutDirectionResolved()public Component.LayoutDirection getLayoutDirectionResolved()
LayoutDirection#RTL if the layout direction is RTL; returns
LayoutDirection#LTR if the layout direction is LTR.Component.LayoutDirection,
setLayoutDirection(LayoutDirection),
getLayoutDirection()public void setFadeEffectBoundaryWidth(int width)
width - Indicates the boundary width to set, in pixels.getFadeEffectBoundaryWidth()public int getFadeEffectBoundaryWidth()
setFadeEffectBoundaryWidth(int)public void setFadeEffectColor(Color color)
color - Indicates the color to set.getFadeEffectColor()public Color getFadeEffectColor()
setFadeEffectColor(Color)protected void onRtlChanged(Component.LayoutDirection layoutDirection)
layoutDirection - Indicates the value of the current layout direction.@Deprecated public void setBoundaryFadeEffectEnable(boolean enable)
enableFadeEffect(FadeEffectEnum) or disableFadeEffect(FadeEffectEnum)enable - Specifies whether to display the boundary of the component's fade-effect area. The value
true indicates that the boundary is displayed, and false indicates the opposite case.@Deprecated public boolean isBoundaryFadeEffectEnable()
isFadeEffected(FadeEffectEnum)true if the boundary is drawn; returns false (default value) otherwise.public float getBoundaryFadeEffectLeftRate()
0.0f.setFadeEffectBoundaryWidth(int)public float getBoundaryFadeEffectTopRate()
0.0f.setFadeEffectBoundaryWidth(int)public float getBoundaryFadeEffectRightRate()
0.0f.setFadeEffectBoundaryWidth(int)public float getBoundaryFadeEffectBottomRate()
0.0f.setFadeEffectBoundaryWidth(int)public void enableSaveState(boolean isEnabled)
isEnabled - Specifies whether this component and its child components can save their states.
The value true means that they can save the states, and false means the opposite.public boolean isSaveStateEnabled()
true if this component and its child components can save their states;
returns false otherwise.protected Sequenceable onSaveState()
If a child class wants to save a specific state, you can override this method.
Sequenceable object that holds the state information.protected void onRestoreState(Sequenceable state)
If a child class wants to restore to a specific state, you can override this method.
state - Indicates the Sequenceable object that holds the state information.protected void dispatchSaveState(PlainArray<Sequenceable> stateContainer)
stateContainer - Indicates the container to hold the state information.protected void dispatchRestoreState(PlainArray<Sequenceable> stateContainer)
stateContainer - Indicates the container that holds the state information to be restored.public void saveComponentTreeState(PlainArray<Sequenceable> stateContainer)
stateContainer - Indicates the container to hold the state information.public void restoreComponentTreeState(PlainArray<Sequenceable> stateContainer)
stateContainer - Indicates a PlainArray object that holds the states to be restored.public void setTransitionSymbol(String symbol)
symbol - Indicates the transition symbol to set.public String getTransitionSymbol()
public int getBaseLine()
-1 if the component does not support baseline alignment.public boolean hasOverlaps()
true if the component has overlapping content; returns false otherwise.