Java android.widget ImageView fields, constructors, methods, implement or subclass

Example usage for Java android.widget ImageView fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.widget ImageView.

The text is from its open source code.

Subclass

android.widget.ImageView has subclasses.
Click this link to see all its subclasses.

Constructor

Method

voidaddOnLayoutChangeListener(OnLayoutChangeListener listener)
Add a listener that will be called when the bounds of the view change due to layout processing.
ViewPropertyAnimatoranimate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
voidbringToFront()
Change the view's z order in the tree, so it's on top of other sibling views.
voidbuildDrawingCache()

Calling this method is equivalent to calling buildDrawingCache(false).

voidclearAnimation()
Cancels any animations for this view.
voidclearColorFilter()
Removes the image's android.graphics.ColorFilter .
voiddestroyDrawingCache()

Frees the resources used by the drawing cache.

voiddraw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
TfindViewById(@IdRes int id)
Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.
floatgetAlpha()
The opacity of the view.
AnimationgetAnimation()
Get the animation currently associated with this view.
DrawablegetBackground()
Gets the background drawable
intgetBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

intgetBottom()
Bottom position of this view relative to its parent.
ContextgetContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
DrawablegetDrawable()
Gets the current Drawable, or null if no Drawable has been assigned.
BitmapgetDrawingCache()

Calling this method is equivalent to calling getDrawingCache(false).

booleangetGlobalVisibleRect(Rect r)
intgetHeight()
Return the height of your view.
intgetId()
Returns this view's identifier.
MatrixgetImageMatrix()
Returns the view's optional matrix.
ViewGroup.LayoutParamsgetLayoutParams()
Get the LayoutParams associated with this view.
intgetLeft()
Left position of this view relative to its parent.
voidgetLocationOnScreen(@Size(2) int[] outLocation)

Computes the coordinates of this view on the screen.

MatrixgetMatrix()
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.
intgetMaxHeight()
The maximum height of this view.
intgetMaxWidth()
The maximum width of this view.
intgetMeasuredHeight()
Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMeasuredWidth()
Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetPaddingBottom()
Returns the bottom padding of this view.
intgetPaddingLeft()
Returns the left padding of this view.
intgetPaddingRight()
Returns the right padding of this view.
intgetPaddingTop()
Returns the top padding of this view.
ViewParentgetParent()
Gets the parent of this view.
ResourcesgetResources()
Returns the resources associated with this view.
intgetRight()
Right position of this view relative to its parent.
ViewgetRootView()

Finds the topmost view in the current view hierarchy.

floatgetRotation()
The degrees that the view is rotated around the pivot point.
ScaleTypegetScaleType()
Returns the current ScaleType that is used to scale the bounds of an image to the bounds of the ImageView.
ObjectgetTag()
Returns this view's tag.
ObjectgetTag(int key)
Returns the tag associated with this view and the specified key.
intgetTop()
Top position of this view relative to its parent.
StringgetTransitionName()
Returns the name of the View to be used to identify Views in Transitions.
ViewTreeObservergetViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy.
intgetVisibility()
Returns the visibility status for this view.
intgetWidth()
Return the width of your view.
IBindergetWindowToken()
Retrieve a unique token identifying the window this view is attached to.
voidinvalidate()
Invalidate the whole view.
booleanisInEditMode()
Indicates whether this View is currently in edit mode.
booleanisSelected()
Indicates the selection state of this view.
voidlayout(int l, int t, int r, int b)
Assign a size and position to a view and all of its descendants

This is the second phase of the layout mechanism.

voidmeasure(int widthMeasureSpec, int heightMeasureSpec)

This is called to find out how big a view should be.

booleanperformClick()
Call this view's OnClickListener, if it is defined.
booleanpost(Runnable action)

Causes the Runnable to be added to the message queue.

booleanpostDelayed(Runnable action, long delayMillis)

Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.

voidpostInvalidate()

Cause an invalidate to happen on a subsequent cycle through the event loop.

booleanremoveCallbacks(Runnable action)

Removes the specified Runnable from the message queue.

voidremoveOnLayoutChangeListener(OnLayoutChangeListener listener)
Remove a listener for layout changes.
booleanrequestFocus()
Call this to try to give focus to a specific view or to one of its descendants.
voidrequestLayout()
Call this when something has changed which has invalidated the layout of this view.
voidsetActivated(boolean activated)
Changes the activated state of this view.
voidsetAdjustViewBounds(boolean adjustViewBounds)
Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.
voidsetAlpha(int alpha)
Sets the alpha value that should be applied to the image.
voidsetAnimation(Animation animation)
Sets the next animation to play for this view.
voidsetBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
voidsetBackgroundColor(@ColorInt int color)
Sets the background color for this view.
voidsetBackgroundDrawable(Drawable background)
voidsetBackgroundResource(@DrawableRes int resid)
Set the background to a given resource.
voidsetClickable(boolean clickable)
Enables or disables click events for this view.
voidsetColorFilter(int color)
Set a tinting option for the image.
voidsetColorFilter(ColorFilter cf)
Apply an arbitrary colorfilter to the image.
voidsetColorFilter(int color, PorterDuff.Mode mode)
Sets a tinting option for the image.
voidsetContentDescription(CharSequence contentDescription)
Sets the View 's content description.
voidsetDrawingCacheEnabled(boolean enabled)

Enables or disables the drawing cache.

voidsetEnabled(boolean enabled)
Set the enabled state of this view.
voidsetFocusable(boolean focusable)
Set whether this view can receive the focus.
voidsetHasTransientState(boolean hasTransientState)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible.
voidsetId(@IdRes int id)
Sets the identifier for this view.
voidsetImageAlpha(int alpha)
Sets the alpha value that should be applied to the image.
voidsetImageBitmap(Bitmap bm)
Sets a Bitmap as the content of this ImageView.
voidsetImageDrawable(@Nullable Drawable drawable)
Sets a drawable as the content of this ImageView.
voidsetImageLevel(int level)
Sets the image level, when it is constructed from a android.graphics.drawable.LevelListDrawable .
voidsetImageMatrix(Matrix matrix)
Adds a transformation Matrix that is applied to the view's drawable when it is drawn.
voidsetImageResourceAsync") public void setImageResource(@DrawableRes int resId)
Sets a drawable as the content of this ImageView.
voidsetImageState(int[] state, boolean merge)
Set the state of the current android.graphics.drawable.StateListDrawable .
voidsetImageTintList(@Nullable ColorStateList tint)
Applies a tint to the image drawable.
voidsetImageURIAsync") public void setImageURI(@Nullable Uri uri)
Sets the content of this ImageView to the specified Uri.
voidsetLayerType(int layerType, @Nullable Paint paint)

Specifies the type of layer backing this view.

voidsetLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view.
voidsetLeft(int left)
Sets the left position of this view relative to its parent.
voidsetMaxHeight(int maxHeight)
An optional argument to supply a maximum height for this view.
voidsetMaxWidth(int maxWidth)
An optional argument to supply a maximum width for this view.
voidsetMinimumHeight(int minHeight)
Sets the minimum height of the view.
voidsetMinimumWidth(int minWidth)
Sets the minimum width of the view.
voidsetOnClickListener(@Nullable OnClickListener l)
Register a callback to be invoked when this view is clicked.
voidsetOnCreateContextMenuListener(OnCreateContextMenuListener l)
Register a callback to be invoked when the context menu for this view is being built.
voidsetOnDragListener(OnDragListener l)
Register a drag event listener callback object for this View.
voidsetOnFocusChangeListener(OnFocusChangeListener l)
Register a callback to be invoked when focus of this view changed.
voidsetOnGenericMotionListener(OnGenericMotionListener l)
Register a callback to be invoked when a generic motion event is sent to this view.
voidsetOnLongClickListener(@Nullable OnLongClickListener l)
Register a callback to be invoked when this view is clicked and held.
voidsetOnTouchListener(OnTouchListener l)
Register a callback to be invoked when a touch event is sent to this view.
voidsetOutlineProvider(ViewOutlineProvider provider)
Sets the ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
voidsetPadding(int left, int top, int right, int bottom)
Sets the padding.
voidsetPivotX(float pivotX)
Sets the x location of the point around which the view is #setRotation(float) rotated and #setScaleX(float) scaled .
voidsetPivotY(float pivotY)
Sets the y location of the point around which the view is #setRotation(float) rotated and #setScaleY(float) scaled .
voidsetRotation(float rotation)
Sets the degrees that the view is rotated around the pivot point.
voidsetRotationY(float rotationY)
Sets the degrees that the view is rotated around the vertical axis through the pivot point.
voidsetScaleType(ScaleType scaleType)
Controls how the image should be resized or moved to match the size of this ImageView.
voidsetScaleX(float scaleX)
Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.
voidsetScaleY(float scaleY)
Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width.
voidsetSelected(boolean selected)
voidsetStateListAnimator(StateListAnimator stateListAnimator)
Attaches the provided StateListAnimator to this View.
voidsetTag(final Object tag)
Sets the tag associated with this view.
voidsetTag(int key, final Object tag)
Sets a tag associated with this view and a key.
voidsetTop(int top)
Sets the top position of this view relative to its parent.
voidsetTransitionName(String transitionName)
Sets the name of the View to be used to identify Views in Transitions.
voidsetTranslationX(float translationX)
Sets the horizontal location of this view relative to its #getLeft() left position.
voidsetTranslationY(float translationY)
Sets the vertical location of this view relative to its #getTop() top position.
voidsetVisibility(int visibility)
voidsetX(float x)
Sets the visual x position of this view, in pixels.
voidsetY(float y)
Sets the visual y position of this view, in pixels.
voidstartAnimation(Animation animation)
Start the specified animation now.
StringtoString()