| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
Image.ScaleMode |
Indicates the scaling mode of images.
|
Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEvent| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
CLIP_DIRECTION_NOT_SET |
Indicates an image clipping direction that is not set.
|
static int |
CLIP_GRAVITY_NOT_SET |
Indicates a clipping alignment mode that is not set.
|
static int |
CLIP_HORIZONTAL |
Indicates the horizontal clipping mode.
|
static int |
CLIP_VERTICAL |
Indicates the vertical clipping mode.
|
static int |
GRAVITY_BOTTOM |
Indicates the bottom alignment mode of clipping images.
|
static int |
GRAVITY_CENTER |
Indicates the center alignment mode of clipping images.
|
static int |
GRAVITY_LEFT |
Indicate the left alignment mode of clipping images.
|
static int |
GRAVITY_RIGHT |
Indicates the right alignment mode of clipping images.
|
static int |
GRAVITY_TOP |
Indicates the top alignment mode of clipping images.
|
ACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLE| 构造器 | 说明 |
|---|---|
Image(Context context) |
Default constructor used to create an
Image instance by using the default attribute set and style. |
Image(Context context,
AttrSet attrSet) |
A constructor used to create an
Image instance by using specified attribute set and default
style after the XML file is parsed. |
Image(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create an
Image instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
getClipAlignment() |
Obtains the image clipping alignment mode.
|
int |
getClipDirection() |
Obtains the image clipping direction.
|
int |
getClipGravity() |
已过时。
This change is effective since API version 5. Replaced by
getClipAlignment() |
float[] |
getCornerRadii() |
Obtains the four corner's radius.
|
float |
getCornerRadius() |
Obtains the corner radius.
|
Element |
getImageElement() |
Get the value of element.
|
int |
getMaxHeight() |
Obtains the maximum height of the
Image object. |
int |
getMaxWidth() |
Obtains the maximum width of the
Image object. |
PixelMap |
getPixelMap() |
Obtains the
PixelMap object displayed on this Image. |
PixelMapHolder |
getPixelMapHolder() |
Obtains the
PixelMapHolder object displayed on this Image. |
Image.ScaleMode |
getScaleMode() |
Obtains the image scaling mode.
|
void |
setClipAlignment(int clipAlignment) |
Sets the clipping alignment mode.
|
void |
setClipDirection(int clipDirection) |
Sets the image clipping direction.
|
void |
setClipGravity(int clipGravity) |
已过时。
This change is effective since API version 5. Replaced by
setClipAlignment() |
void |
setCornerRadii(float[] radii) |
Sets a radius for each rounded corner of this
Image. |
void |
setCornerRadius(float radius) |
Sets a uniform radius for the four rounded corners of this
Image. |
void |
setImageAndDecodeBounds(int resId) |
Sets the resource ID of the image to be displayed and decodes the image.
|
void |
setImageElement(Element element) |
Sets the
Element to be displayed for this Image. |
void |
setMaxHeight(int value) |
Sets the maximum height of the
Image object. |
void |
setMaxWidth(int value) |
Sets the maximum width of the
Image object. |
void |
setPixelMap(int resId) |
Sets the resource ID of an image to display.
|
void |
setPixelMap(PixelMap pixelMap) |
Sets the image to be displayed on a component.
|
void |
setPixelMapHolder(PixelMapHolder pixelMapHolder) |
Sets a
PixelMapHolder object to be displayed for this Image. |
void |
setScaleMode(Image.ScaleMode scaleMode) |
Sets the scaling mode of an image.
|
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, dispatchRestoreState, dispatchSaveState, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findComponentById, findComponentHolderById, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectBoundaryWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, informConfigurationChanged, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onDrag, onRestoreState, onRtlChanged, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectBoundaryWidth, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventspublic static final int CLIP_DIRECTION_NOT_SET
public static final int CLIP_GRAVITY_NOT_SET
public static final int CLIP_HORIZONTAL
public static final int CLIP_VERTICAL
public static final int GRAVITY_BOTTOM
public static final int GRAVITY_CENTER
public static final int GRAVITY_LEFT
public static final int GRAVITY_RIGHT
public static final int GRAVITY_TOP
public Image(Context context)
Image instance by using the default attribute set and style.context - Indicates the application context.public Image(Context context, AttrSet attrSet)
Image 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 Image(Context context, AttrSet attrSet, String styleName)
Image 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 void setPixelMapHolder(PixelMapHolder pixelMapHolder)
PixelMapHolder object to be displayed for this Image.
This method can be more efficient than setPixelMap(ohos.media.image.PixelMap) when it is called in a single thread.
pixelMapHolder - Indicates the image object.public PixelMapHolder getPixelMapHolder()
PixelMapHolder object displayed on this Image.PixelMapHolder object displayed on this Image.setPixelMapHolder(PixelMapHolder)public void setPixelMap(PixelMap pixelMap)
pixelMap - Indicates the image object.public PixelMap getPixelMap()
PixelMap object displayed on this Image.PixelMap object displayed on this Image.public void setImageElement(Element element)
Element to be displayed for this Image.element - Indicates the element to set.public Element getImageElement()
public void setImageAndDecodeBounds(int resId)
This interface will scale the picture according to the size of the component. Using this interface to set the same resource id on different components may cause some of them to display blurry. Please use this interface with caution.
resId - Indicates the resource ID of the image to display.public void setPixelMap(int resId)
resId - Indicates the resource ID of the image to display.public void setClipDirection(int clipDirection)
If the size of an image exceeds that of the component, the image can be clipped horizontally or vertically. Horizontal clipping does not change the vertical contents of the image. Vertical clipping does not change the horizontal contents of the image.
clipDirection - Specifies the image clipping direction. 1 indicates CLIP_HORIZONTAL,
which is horizontal clipping; 2 indicates CLIP_VERTICAL, which is
vertical clipping.public int getClipDirection()
setClipDirection(int)@Deprecated public void setClipGravity(int clipGravity)
setClipAlignment()This method sets the clipping alignment mode. For example, if the value is GRAVITY_LEFT, the right
part of the image will be clipped when the width of the image exceeds that of the component.
clipGravity - Specifies the clipping mode by using static consonants in Image, for example,
GRAVITY_LEFT.@Deprecated public int getClipGravity()
getClipAlignment()setClipGravity(int)public void setClipAlignment(int clipAlignment)
This method sets the clipping alignment mode. For example, if the value is GRAVITY_LEFT, the right
part of the image will be clipped when the width of the image exceeds that of the component.
clipAlignment - Specifies the clipping mode by using static consonants in Image, for example,
GRAVITY_LEFT.public int getClipAlignment()
setClipAlignment(int)public void setScaleMode(Image.ScaleMode scaleMode)
This method scales or clips an image when the sizes of the image and the component are different. For
details of
scaling modes, see ScaleMode.
scaleMode - Indicates the ScaleMode enumeration value, which specifies the scaling mode.public Image.ScaleMode getScaleMode()
setScaleMode(ScaleMode)public void setCornerRadius(float radius)
Image.radius - Indicates the radius to set. The value of this parameter must be greater than 0.
If the value is less than or equal to 0, the setting is invalid.public float getCornerRadius()
public void setCornerRadii(float[] radii)
Image.radii - Indicates the array of radii to set.public float[] getCornerRadii()
public void setMaxHeight(int value)
Image object.
Use this method only when the height of the Image object is set as MATCH_CONTENT.
value - Indicates the maximum height of the Image object.IllegalArgumentException - Throws this exception if the specified height is less than 0.public int getMaxHeight()
Image object.Image object.public void setMaxWidth(int value)
Image object.
Use this method only when the width of the Image object is set as MATCH_CONTENT.
value - Indicates the maximum width of the Image object.IllegalArgumentException - Throws this exception if the specified width is less than 0.public int getMaxWidth()
Image object.Image object.