IT. Expert System.

Android Reference

ImageView


android.widget

Class ImageView

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback
    Direct Known Subclasses:
    ImageButton, QuickContactBadge


    public class ImageView
    extends View
    Displays an arbitrary image, such as an icon. The ImageView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the image so that it can be used in any layout manager, and provides various display options such as scaling and tinting.
    • Method Detail

      • verifyDrawable

        protected boolean verifyDrawable(Drawable dr)
        Description copied from class: View
        If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

        Be sure to call through to the super class when overriding this function.

        Overrides:
        verifyDrawable in class View
        Parameters:
        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.
        Returns:
        boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.
        See Also:
        View.unscheduleDrawable(android.graphics.drawable.Drawable), View.drawableStateChanged()
      • hasOverlappingRendering

        public boolean hasOverlappingRendering()
        Description copied from class: View
        Returns whether this View has content which overlaps. 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 it 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.
        Overrides:
        hasOverlappingRendering in class View
        Returns:
        true if the content in this view might overlap, false otherwise.
      • getAdjustViewBounds

        public boolean getAdjustViewBounds()
        True when ImageView is adjusting its bounds to preserve the aspect ratio of its drawable
        Returns:
        whether to adjust the bounds of this view to presrve the original aspect ratio of the drawable
        See Also:
        setAdjustViewBounds(boolean)
      • setAdjustViewBounds

        public 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.
        Parameters:
        adjustViewBounds - Whether to adjust the bounds of this view to presrve the original aspect ratio of the drawable
        See Also:
        getAdjustViewBounds()
      • getMaxWidth

        public int getMaxWidth()
        The maximum width of this view.
        Returns:
        The maximum width of this view
        See Also:
        setMaxWidth(int)
      • setMaxWidth

        public void setMaxWidth(int maxWidth)
        An optional argument to supply a maximum width for this view. Only valid if 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.

        Parameters:
        maxWidth - maximum width for this view
        See Also:
        getMaxWidth()
      • getMaxHeight

        public int getMaxHeight()
        The maximum height of this view.
        Returns:
        The maximum height of this view
        See Also:
        setMaxHeight(int)
      • setMaxHeight

        public void setMaxHeight(int maxHeight)
        An optional argument to supply a maximum height for this view. Only valid if 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.

        Parameters:
        maxHeight - maximum height for this view
        See Also:
        getMaxHeight()
      • getDrawable

        public Drawable getDrawable()
        Return the view's drawable, or null if no drawable has been assigned.
      • setImageDrawable

        public void setImageDrawable(Drawable drawable)
        Sets a drawable as the content of this ImageView.
        Parameters:
        drawable - The drawable to set
      • setImageBitmap

        public void setImageBitmap(Bitmap bm)
        Sets a Bitmap as the content of this ImageView.
        Parameters:
        bm - The bitmap to set
      • setImageState

        public void setImageState(int[] state,
                         boolean merge)
      • setSelected

        public void setSelected(boolean selected)
        Description copied from class: View
        Changes the selection state of this view. A view can be selected or not. Note that selection is not the same as focus. Views are typically selected in the context of an AdapterView like ListView or GridView; the selected view is the view that is highlighted.
        Overrides:
        setSelected in class View
        Parameters:
        selected - true if the view must be selected, false otherwise
      • setImageLevel

        public void setImageLevel(int level)
        Sets the image level, when it is constructed from a LevelListDrawable.
        Parameters:
        level - The new level for the image.
      • setScaleType

        public void setScaleType(ImageView.ScaleType scaleType)
        Controls how the image should be resized or moved to match the size of this ImageView.
        Parameters:
        scaleType - The desired scaling mode.
      • getImageMatrix

        public Matrix getImageMatrix()
        Return the view's optional matrix. This is applied to the view's drawable when it is drawn. If there is not matrix, this method will return null. Do not change this matrix in place. If you want a different matrix applied to the drawable, be sure to call setImageMatrix().
      • setImageMatrix

        public void setImageMatrix(Matrix matrix)
      • getCropToPadding

        public boolean getCropToPadding()
        Return whether this ImageView crops to padding.
        Returns:
        whether this ImageView crops to padding
        See Also:
        setCropToPadding(boolean)
      • setCropToPadding

        public void setCropToPadding(boolean cropToPadding)
        Sets whether this ImageView will crop to padding.
        Parameters:
        cropToPadding - whether this ImageView will crop to padding
        See Also:
        getCropToPadding()
      • onCreateDrawableState

        public int[] onCreateDrawableState(int extraSpace)
        Description copied from class: View
        Generate the new 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().
        Overrides:
        onCreateDrawableState in class View
        Parameters:
        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.
        Returns:
        Returns an array holding the current Drawable state of the view.
        See Also:
        View.mergeDrawableStates(int[], int[])
      • setFrame

        protected boolean setFrame(int l,
                       int t,
                       int r,
                       int b)
        Description copied from class: View
        Assign a size and position to this view. This is called from layout.
        Overrides:
        setFrame in class View
        Parameters:
        l - Left position, relative to parent
        t - Top position, relative to parent
        r - Right position, relative to parent
        b - Bottom position, relative to parent
        Returns:
        true if the new size and position are different than the previous ones
      • drawableStateChanged

        protected void drawableStateChanged()
        Description copied from class: View
        This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

        Be sure to call through to the superclass when overriding this function.

        Overrides:
        drawableStateChanged in class View
        See Also:
        Drawable.setState(int[])
      • onDraw

        protected void onDraw(Canvas canvas)
        Description copied from class: View
        Implement this to do your drawing.
        Overrides:
        onDraw in class View
        Parameters:
        canvas - the canvas on which the background will be drawn
      • getBaseline

        public int getBaseline()

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

        Overrides:
        getBaseline in class View
        Returns:
        the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported.
      • setBaseline

        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.

        Parameters:
        baseline - The baseline to use, or -1 if none is to be provided.
        See Also:
        setBaseline(int)
      • setBaselineAlignBottom

        public void setBaselineAlignBottom(boolean aligned)
        Set whether to set the baseline of this view to the bottom of the view. Setting this value overrides any calls to setBaseline.
        Parameters:
        aligned - If true, the image view will be baseline aligned with based on its bottom edge.
      • getBaselineAlignBottom

        public boolean getBaselineAlignBottom()
        Return whether this view's baseline will be considered the bottom of the view.
        See Also:
        setBaselineAlignBottom(boolean)
      • setColorFilter

        public final void setColorFilter(int color,
                          PorterDuff.Mode mode)
        Set a tinting option for the image.
        Parameters:
        color - Color tint to apply.
        mode - How to apply the color. The standard mode is PorterDuff.Mode#SRC_ATOP
      • setColorFilter

        public final void setColorFilter(int color)
        Set a tinting option for the image. Assumes PorterDuff.Mode#SRC_ATOP blending mode.
        Parameters:
        color - Color tint to apply.
      • clearColorFilter

        public final void clearColorFilter()
      • setColorFilter

        public void setColorFilter(ColorFilter cf)
        Apply an arbitrary colorfilter to the image.
        Parameters:
        cf - the colorfilter to apply (may be null)
        See Also:
        getColorFilter()
      • getImageAlpha

        public int getImageAlpha()
        Returns the alpha that will be applied to the drawable of this ImageView.
        Returns:
        the alpha that will be applied to the drawable of this ImageView
        See Also:
        setImageAlpha(int)
      • setImageAlpha

        public void setImageAlpha(int alpha)
        Sets the alpha value that should be applied to the image.
        Parameters:
        alpha - the alpha value that should be applied to the image
        See Also:
        getImageAlpha()
      • setAlpha

        @Deprecated
        public void setAlpha(int alpha)
        Deprecated. use #setImageAlpha(int) instead
        Sets the alpha value that should be applied to the image.
        Parameters:
        alpha - the alpha value that should be applied to the image
      • onDetachedFromWindow

        protected void onDetachedFromWindow()
        Description copied from class: View
        This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
        Overrides:
        onDetachedFromWindow in class View
        See Also:
        View.onAttachedToWindow()


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 733 / 159198303. Delta: 0.05172 с