English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.ImageView

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.widget.ImageView

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.

Nested Classes
Known Direct Subclasses

Summary

XML Attributes

Attribute name Related methods  
android:adjustViewBounds setAdjustViewBounds(boolean)
 
 
android:maxHeight setMaxHeight(int)
 
Makes the TextView be at most this many pixels tall

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:maxWidth setMaxWidth(int)
 
Makes the TextView be at most this many pixels wide

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 

android:scaleType setScaleType(ImageView.ScaleType)
 
 
android:src    
android:tint setColorFilter(int,PorterDuff.Mode)
 
 
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.View

Fields

public      boolean  mShouldFit   
public      boolean  mWarned   
Fields inherited from class android.view.View

Public Constructors

          ImageView(Context context)
          ImageView(Context context, AttributeSet attrs, Map inflateParams)
          ImageView(Context context, AttributeSet attrs, Map inflateParams, int defStyle)

Public Methods

    final    void  clearColorFilter()
        Drawable  getDrawable()
Return the view's drawable, or null if no drawable has been assigned.
        Matrix  getImageMatrix()
Return the view's optional matrix.
        void  invalidateDrawable(Drawable dr)
Invalidates the specified Drawable.
        int[]  onCreateDrawableState(int extraSpace)
Generate the new Drawable state for this view.
        int  resolveAdjustedSize(int desiredSize, int maxSize, int measureSpec)
        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)
        void  setColorFilter(ColorFilter cf)
Apply an arbitrary colorfilter to the image.
    final    void  setColorFilter(int color, Mode mode)
Set a tinting option for the image.
        void  setImageBitmap(Bitmap bm)
        void  setImageDrawable(Drawable drawable)
        void  setImageLevel(int level)
        void  setImageMatrix(Matrix matrix)
        void  setImageResource(int resid)
        void  setImageState(int[] state, boolean merge)
        void  setImageURI(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(ScaleType scaleType)
Control 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.
        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.

Protected Methods

        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.
        void  onDraw(Canvas canvas)
Implement this to do your drawing.
        void  onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

        boolean  setFrame(int l, int t, int r, int b)
Assign a size and position to this view.
Methods inherited from class android.view.View