public class ImageView extends View
Modifier and Type | Class and Description |
---|---|
static class |
ImageView.ScaleType
Options for scaling the bounds of an image to the bounds of this view.
|
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, SYSTEM_UI_TRANSPARENT, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
Constructor and Description |
---|
ImageView(Context context) |
ImageView(Context context,
AttributeSet attrs) |
ImageView(Context context,
AttributeSet attrs,
int defStyleAttr) |
ImageView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
Modifier and Type | Method and Description |
---|---|
void |
animateTransform(Matrix matrix) |
void |
clearColorFilter() |
void |
drawableHotspotChanged(float x,
float y)
This function is called whenever the view hotspot changes and needs to
be propagated to drawables or child views managed by the view.
|
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
protected void |
encodeProperties(ViewHierarchyEncoder stream) |
CharSequence |
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
|
boolean |
getAdjustViewBounds()
True when ImageView is adjusting its bounds
to preserve the aspect ratio of its drawable
|
int |
getBaseline()
Return the offset of the widget's text baseline from the widget's top
boundary.
|
boolean |
getBaselineAlignBottom()
Return whether this view's baseline will be considered the bottom of the view.
|
ColorFilter |
getColorFilter()
Returns the active color filter for this ImageView.
|
boolean |
getCropToPadding()
Return whether this ImageView crops to padding.
|
Drawable |
getDrawable()
Return the view's drawable, or null if no drawable has been
assigned.
|
int |
getImageAlpha()
Returns the alpha that will be applied to the drawable of this ImageView.
|
Matrix |
getImageMatrix()
Return the view's optional matrix.
|
ColorStateList |
getImageTintList() |
PorterDuff.Mode |
getImageTintMode() |
int |
getMaxHeight()
The maximum height of this view.
|
int |
getMaxWidth()
The maximum width of this view.
|
ImageView.ScaleType |
getScaleType()
Return the current scale type in use by this ImageView.
|
boolean |
hasOverlappingRendering()
Returns whether this View has content which overlaps.
|
void |
invalidateDrawable(Drawable dr)
Invalidates the specified Drawable.
|
boolean |
isOpaque()
Indicates whether this View is opaque.
|
void |
jumpDrawablesToCurrentState()
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view. |
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
int[] |
onCreateDrawableState(int extraSpace)
Generate the new
Drawable state for
this view. |
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
protected void |
onDraw(Canvas canvas)
Implement this to do your drawing.
|
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the
measured height.
|
void |
onPopulateAccessibilityEventInternal(AccessibilityEvent event) |
void |
onRtlPropertiesChanged(int layoutDirection)
Called when any RTL property (layout direction or text direction or text alignment) has
been changed.
|
void |
onVisibilityAggregated(boolean isVisible)
Called when the user-visibility of this View is potentially affected by a change
to this view itself, an ancestor view or the window this view is attached to.
|
void |
setAdjustViewBounds(boolean adjustViewBounds)
Set this to true if you want the ImageView to adjust its bounds
to preserve the aspect ratio of its drawable.
|
void |
setAlpha(int alpha)
Deprecated.
use #setImageAlpha(int) instead
|
void |
setBaseline(int baseline)
Set the offset of the widget's text baseline from the widget's top
boundary.
|
void |
setBaselineAlignBottom(boolean aligned)
Set whether to set the baseline of this view to the bottom of the view.
|
void |
setColorFilter(ColorFilter cf)
Apply an arbitrary colorfilter to the image.
|
void |
setColorFilter(int color)
Set a tinting option for the image.
|
void |
setColorFilter(int color,
PorterDuff.Mode mode)
Set a tinting option for the image.
|
void |
setCropToPadding(boolean cropToPadding)
Sets whether this ImageView will crop to padding.
|
protected boolean |
setFrame(int l,
int t,
int r,
int b)
Assign a size and position to this view.
|
void |
setImageAlpha(int alpha)
Sets the alpha value that should be applied to the image.
|
void |
setImageBitmap(Bitmap bm)
Sets a Bitmap as the content of this ImageView.
|
void |
setImageDrawable(Drawable drawable)
Sets a drawable as the content of this ImageView.
|
void |
setImageIcon(Icon icon)
Sets the content of this ImageView to the specified Icon.
|
Runnable |
setImageIconAsync(Icon icon) |
void |
setImageLevel(int level)
Sets the image level, when it is constructed from a
LevelListDrawable . |
void |
setImageMatrix(Matrix matrix)
Adds a transformation
Matrix that is applied
to the view's drawable when it is drawn. |
void |
setImageResource(int resId)
Sets a drawable as the content of this ImageView.
|
Runnable |
setImageResourceAsync(int resId) |
void |
setImageState(int[] state,
boolean merge) |
void |
setImageTintList(ColorStateList tint)
Applies a tint to the image drawable.
|
void |
setImageTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
setImageTintList(ColorStateList) } to the image drawable. |
void |
setImageURI(Uri uri)
Sets the content of this ImageView to the specified Uri.
|
Runnable |
setImageURIAsync(Uri uri) |
void |
setMaxHeight(int maxHeight)
An optional argument to supply a maximum height for this view.
|
void |
setMaxWidth(int maxWidth)
An optional argument to supply a maximum width for this view.
|
void |
setScaleType(ImageView.ScaleType scaleType)
Controls how the image should be resized or moved to match the size
of this ImageView.
|
void |
setSelected(boolean selected)
Changes the selection state of this view.
|
void |
setVisibility(int visibility)
Set the visibility state of this view.
|
void |
setXfermode(Xfermode mode) |
protected boolean |
verifyDrawable(Drawable dr)
If your view subclass is displaying its own Drawable objects, it should
override this function and return true for any Drawable it is
displaying.
|
addChildrenForAccessibility, addFocusables, addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, captureTransitioningViews, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, clearFocus, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, createSnapshot, damageInParent, debug, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchActivityResult, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, encode, findFocus, findNamedViews, findViewByAccessibilityIdTraversal, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewByPredicateTraversal, findViewsWithText, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, gatherTransparentRegion, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasFocus, hasFocusable, hasHoveredChild, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasShadow, hasTransientState, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, internalSetPadding, invalidate, invalidate, invalidate, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isAccessibilitySelectionExtendable, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, layout, makeOptionalFitsSystemWindows, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onActivityResult, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindowInternal, onDisplayHint, onDragEvent, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityEventInternal, onInitializeAccessibilityNodeInfo, onInitializeAccessibilityNodeInfoInternal, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onOverScrolled, onPopulateAccessibilityEvent, onProvideStructure, onProvideVirtualStructure, onRenderNodeDetached, onResolveDrawables, onResolvePointerIcon, onRestoreInstanceState, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performAccessibilityActionInternal, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetResolvedDrawables, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resetRtlProperties, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventInternal, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilitySelection, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, willNotCacheDrawing, willNotDraw
public ImageView(Context context)
public ImageView(Context context, AttributeSet attrs)
public ImageView(Context context, AttributeSet attrs, int defStyleAttr)
public ImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
protected boolean verifyDrawable(Drawable dr)
View
Be sure to call through to the super class when overriding this function.
verifyDrawable
in class View
dr
- The Drawable to verify. Return true if it is one you are
displaying, else return the result of calling through to the
super class.View.unscheduleDrawable(android.graphics.drawable.Drawable)
,
View.drawableStateChanged()
public void jumpDrawablesToCurrentState()
View
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.
Also calls StateListAnimator.jumpToCurrentState()
if there is a StateListAnimator
attached to this view.
jumpDrawablesToCurrentState
in class View
public void invalidateDrawable(Drawable dr)
View
invalidateDrawable
in interface Drawable.Callback
invalidateDrawable
in class View
dr
- the drawable to invalidatepublic boolean hasOverlappingRendering()
View
This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited into place, which can be expensive. If the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. An example of overlapping rendering is a TextView with a background image, such as a Button. An example of non-overlapping rendering is a TextView with no background, or an ImageView with only the foreground image. The default implementation returns true; subclasses should override if they have cases which can be optimized.
The current implementation of the saveLayer and saveLayerAlpha methods in Canvas
necessitates that a View return true if it uses the methods internally without passing the
Canvas.CLIP_TO_LAYER_SAVE_FLAG
.
Note: The return value of this method is ignored if View.forceHasOverlappingRendering(boolean)
has been called on this view.
hasOverlappingRendering
in class View
public void onPopulateAccessibilityEventInternal(AccessibilityEvent event)
onPopulateAccessibilityEventInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
public boolean getAdjustViewBounds()
setAdjustViewBounds(boolean)
public void setAdjustViewBounds(boolean adjustViewBounds)
Note: If the application targets API level 17 or lower,
adjustViewBounds will allow the drawable to shrink the view bounds, but not grow
to fill available measured space in all cases. This is for compatibility with
legacy MeasureSpec
and
RelativeLayout
behavior.
adjustViewBounds
- Whether to adjust the bounds of this view
to preserve the original aspect ratio of the drawable.getAdjustViewBounds()
public int getMaxWidth()
setMaxWidth(int)
public void setMaxWidth(int maxWidth)
setAdjustViewBounds(boolean)
has been set to true. To set an image to be a maximum
of 100 x 100 while preserving the original aspect ratio, do the following: 1) set
adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width
layout params to WRAP_CONTENT.
Note that this view could be still smaller than 100 x 100 using this approach if the original
image is small. To set an image to a fixed size, specify that size in the layout params and
then use setScaleType(android.widget.ImageView.ScaleType)
to determine how to fit
the image within the bounds.
maxWidth
- maximum width for this viewgetMaxWidth()
public int getMaxHeight()
setMaxHeight(int)
public void setMaxHeight(int maxHeight)
setAdjustViewBounds(boolean)
has been set to true. To set an image to be a
maximum of 100 x 100 while preserving the original aspect ratio, do the following: 1) set
adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width
layout params to WRAP_CONTENT.
Note that this view could be still smaller than 100 x 100 using this approach if the original
image is small. To set an image to a fixed size, specify that size in the layout params and
then use setScaleType(android.widget.ImageView.ScaleType)
to determine how to fit
the image within the bounds.
maxHeight
- maximum height for this viewgetMaxHeight()
public Drawable getDrawable()
public void setImageResource(@DrawableRes int resId)
This does Bitmap reading and decoding on the UI
thread, which can cause a latency hiccup. If that's a concern,
consider using setImageDrawable(android.graphics.drawable.Drawable)
or
setImageBitmap(android.graphics.Bitmap)
and
BitmapFactory
instead.
resId
- the resource identifier of the drawablepublic Runnable setImageResourceAsync(@DrawableRes int resId)
public void setImageURI(Uri uri)
This does Bitmap reading and decoding on the UI
thread, which can cause a latency hiccup. If that's a concern,
consider using setImageDrawable(Drawable)
or
setImageBitmap(android.graphics.Bitmap)
and
BitmapFactory
instead.
On devices running SDK < 24, this method will fail to
apply correct density scaling to images loaded from
content
and
file
schemes. Applications running
on devices with SDK >= 24 MUST specify the
targetSdkVersion
in their manifest as 24 or above for density
scaling to be applied to images loaded from these schemes.
uri
- the Uri of an image, or null
to clear the contentpublic void setImageDrawable(Drawable drawable)
drawable
- the Drawable to set, or null
to clear the
contentpublic void setImageIcon(Icon icon)
Depending on the Icon type, this may do Bitmap reading
and decoding on the UI thread, which can cause UI jank. If that's a
concern, consider using
Icon.loadDrawableAsync(Context, Icon.OnDrawableLoadedListener, Handler)
and then setImageDrawable(android.graphics.drawable.Drawable)
instead.
icon
- an Icon holding the desired image, or null
to clear
the contentpublic void setImageTintList(ColorStateList tint)
PorterDuff.Mode#SRC_IN
by default.
Subsequent calls to setImageDrawable(Drawable)
will automatically
mutate the drawable and apply the specified tint and tint mode using
Drawable.setTintList(ColorStateList)
.
Note: The default tint mode used by this setter is NOT
consistent with the default tint mode used by the
android:tint
attribute. If the android:tint
attribute is specified, the
default tint mode will be set to PorterDuff.Mode#SRC_ATOP
to
ensure consistency with earlier versions of the platform.
tint
- the tint to apply, may be null
to clear tintgetImageTintList()
,
Drawable.setTintList(ColorStateList)
public ColorStateList getImageTintList()
setImageTintList(ColorStateList)
public void setImageTintMode(PorterDuff.Mode tintMode)
setImageTintList(ColorStateList)
} to the image drawable. The default
mode is PorterDuff.Mode#SRC_IN
.tintMode
- the blending mode used to apply the tint, may be
null
to clear tintgetImageTintMode()
,
Drawable.setTintMode(PorterDuff.Mode)
public PorterDuff.Mode getImageTintMode()
setImageTintMode(PorterDuff.Mode)
public void setImageBitmap(Bitmap bm)
bm
- The bitmap to setpublic void setImageState(int[] state, boolean merge)
public void setSelected(boolean selected)
View
setSelected
in class View
selected
- true if the view must be selected, false otherwisepublic void setImageLevel(int level)
LevelListDrawable
.level
- The new level for the image.public void setScaleType(ImageView.ScaleType scaleType)
scaleType
- The desired scaling mode.public ImageView.ScaleType getScaleType()
ImageView.ScaleType
public Matrix getImageMatrix()
public void setImageMatrix(Matrix matrix)
Matrix
that is applied
to the view's drawable when it is drawn. Allows custom scaling,
translation, and perspective distortion.matrix
- the transformation parameters in matrix formpublic boolean getCropToPadding()
setCropToPadding(boolean)
public void setCropToPadding(boolean cropToPadding)
cropToPadding
- whether this ImageView will crop to paddinggetCropToPadding()
public int[] onCreateDrawableState(int extraSpace)
View
Drawable
state for
this view. This is called by the view
system when the cached Drawable state is determined to be invalid. To
retrieve the current state, you should use View.getDrawableState()
.onCreateDrawableState
in class View
extraSpace
- if non-zero, this is the number of extra entries you
would like in the returned array in which you can place your own
states.Drawable
state of
the view.View.mergeDrawableStates(int[], int[])
public void onRtlPropertiesChanged(int layoutDirection)
View
onRtlPropertiesChanged
in class View
layoutDirection
- the direction of the layoutView.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int)
and
should be overridden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call View.setMeasuredDimension(int, int)
to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
View.measure(int, int)
. Calling the superclass'
View.onMeasure(int, int)
is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int)
to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight()
and
View.getSuggestedMinimumWidth()
).
onMeasure
in class View
widthMeasureSpec
- horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.heightMeasureSpec
- vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.View.getMeasuredWidth()
,
View.getMeasuredHeight()
,
View.setMeasuredDimension(int, int)
,
View.getSuggestedMinimumHeight()
,
View.getSuggestedMinimumWidth()
,
View.MeasureSpec.getMode(int)
,
View.MeasureSpec.getSize(int)
protected boolean setFrame(int l, int t, int r, int b)
View
protected void drawableStateChanged()
View
If the View has a StateListAnimator, it will also be called to run necessary state change animations.
Be sure to call through to the superclass when overriding this function.
drawableStateChanged
in class View
Drawable.setState(int[])
public void drawableHotspotChanged(float x, float y)
View
Dispatching to child views is handled by
View.dispatchDrawableHotspotChanged(float, float)
.
Be sure to call through to the superclass when overriding this function.
drawableHotspotChanged
in class View
x
- hotspot x coordinatey
- hotspot y coordinatepublic void animateTransform(Matrix matrix)
protected void onDraw(Canvas canvas)
View
public int getBaseline()
Return the offset of the widget's text baseline from the widget's top boundary.
getBaseline
in class View
public void setBaseline(int baseline)
Set the offset of the widget's text baseline from the widget's top
boundary. This value is overridden by the setBaselineAlignBottom(boolean)
property.
baseline
- The baseline to use, or -1 if none is to be provided.setBaseline(int)
public void setBaselineAlignBottom(boolean aligned)
aligned
- If true, the image view will be baseline aligned with
based on its bottom edge.public boolean getBaselineAlignBottom()
setBaselineAlignBottom(boolean)
public final void setColorFilter(int color, PorterDuff.Mode mode)
color
- Color tint to apply.mode
- How to apply the color. The standard mode is
PorterDuff.Mode#SRC_ATOP
public final void setColorFilter(int color)
PorterDuff.Mode#SRC_ATOP
blending mode.color
- Color tint to apply.public final void clearColorFilter()
public final void setXfermode(Xfermode mode)
public ColorFilter getColorFilter()
setColorFilter(android.graphics.ColorFilter)
public void setColorFilter(ColorFilter cf)
cf
- the colorfilter to apply (may be null)getColorFilter()
public int getImageAlpha()
setImageAlpha(int)
public void setImageAlpha(int alpha)
alpha
- the alpha value that should be applied to the image (between
0 and 255 inclusive, with 0 being transparent and 255 being opaque)getImageAlpha()
@Deprecated public void setAlpha(int alpha)
alpha
- the alpha value that should be applied to the imagepublic boolean isOpaque()
View
public void onVisibilityAggregated(boolean isVisible)
View
onVisibilityAggregated
in class View
isVisible
- true if this view and all of its ancestors are View.VISIBLE
and this view's window is also visiblepublic void setVisibility(int visibility)
View
setVisibility
in class View
visibility
- One of View.VISIBLE
, View.INVISIBLE
, or View.GONE
.protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class View
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class View
View.onAttachedToWindow()
public CharSequence getAccessibilityClassName()
View
AccessibilityNodeInfo.setClassName
.getAccessibilityClassName
in class View
protected void encodeProperties(ViewHierarchyEncoder stream)
View
encodeProperties
in class View