Best code examples for Android ImageView class (android.widget.ImageView)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ImageView class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android ImageView examples from Open Source projects
Examples using Android ImageView setImageDrawable method:
This code example shows how to use the following methods: setImageDrawable, setVisibility, getVisibility
218:	mIconView.setImageDrawable(showIcon ? icon : null); 
-
220:	if (mIconView.getVisibility() != VISIBLE) { 
221:	mIconView.setVisibility(VISIBLE); 
-
224:	mIconView.setVisibility(GONE); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setImageDrawable, setImageResource, setVisibility
168:	mAirplane.setImageDrawable(null); 
-
205:	mAirplane.setImageResource(mAirplaneIconId); 
206:	mAirplane.setVisibility(View.VISIBLE); 
-
208:	mAirplane.setVisibility(View.GONE); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: setImageDrawable, setVisibility, getVisibility
212:	mIconView.setImageDrawable(showIcon ? icon : null); 
-
214:	if (mIconView.getVisibility() != VISIBLE) { 
215:	mIconView.setVisibility(VISIBLE); 
-
218:	mIconView.setVisibility(GONE); 
Full Snippet Info
8
CodeRank
Examples using Android ImageView setImageBitmap method:
This code example shows how to use the following methods: setImageBitmap, setScaleType, setLayoutParams, setPadding
92:	imageView = new ImageView(mContext); 
93:	imageView.setLayoutParams(new GridView.LayoutParams(50, 50)); 
94:	imageView.setScaleType(ImageView.ScaleType.FIT_XY); 
95:	imageView.setPadding(4, 4, 4, 4); 
-
101:	imageView.setImageBitmap(emotions.get(index.get(position))); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageBitmap, getTag, invalidate
54:	if (path.equals(image.getTag())) { 
55:	image.setImageBitmap(bitmap); 
56:	image.invalidate(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageBitmap, setImageDrawable, clearAnimation, getAnimation, getContext
94:	if (!equals(view.getTag())) 
-
97:	view.setTag(null); 
-
99:	if (fadeIn && view.getAnimation() == null) 
100:	view.startAnimation(AnimationUtils.loadAnimation(view.getContext(), 
-
102:	view.setImageBitmap(result); 
-
104:	view.setImageDrawable(null); 
105:	view.clearAnimation(); 
Full Snippet Info
8
CodeRank
Examples using Android ImageView setImageResource method:
This code example shows how to use the following methods: setImageResource, setScaleType
63:	ImageView i = new ImageView(mContext); 
64:	i.setImageResource(mImageIds[position]); 
65:	i.setScaleType(ScaleType.CENTER_INSIDE); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setImageResource, setScaleType, setBackgroundResource, setLayoutParams
120:	convertView = new ImageView(mContext); 
-
123:	imageView.setScaleType(ImageView.ScaleType.FIT_XY); 
124:	imageView.setLayoutParams(new Gallery.LayoutParams( 
-
129:	imageView.setBackgroundResource(mGalleryItemBackground); 
-
134:	imageView.setImageResource(mImageIds[position]); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageResource, setScaleType, setLayoutParams
40:	ImageView imageView = new ImageView(_context); 
41:	imageView.setImageResource(imageIds[postion]); 
42:	imageView.setScaleType(ScaleType.FIT_XY); 
43:	imageView.setLayoutParams(new Gallery.LayoutParams(400, 400)); 
Full Snippet Info
7
CodeRank
Examples using Android ImageView getDrawable method:
This code example shows how to use the following methods: getDrawable, setImageDrawable, getTag, setTag
181:	if (thumbImageView.getTag() != null 
182:	&& thumbImageView.getTag().equals(tempThumbnailImageFileName)) { 
-
187:	final BitmapWorkerTask task = new BitmapWorkerTask(thumbImageView, 
-
192:	thumbImageView.setImageDrawable(asyncDrawable); 
193:	thumbImageView.setTag(tempThumbnailImageFileName); 
-
231:	final Drawable drawable = imageView.getDrawable(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getDrawable, setImageMatrix, layout
262:	Drawable d = imageView.getDrawable(); 
-
391:	imageView.setImageMatrix(getViewMatrix()); 
-
399:	imageView.layout(parentLeft, parentTop, parentRight, parentBottom); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getDrawable, getBackground, getHeight, getPaddingBottom, getPaddingTop
71:	int nextHeight = Math.max(mNext.getDrawable().getIntrinsicHeight() + mNext.getPaddingTop() 
72:	+ mNext.getPaddingBottom(), 
73:	mNext.getBackground().getMinimumHeight()); 
-
77:	assertEquals("Next incorrect height", nextHeight, mNext.getHeight()); 
-
80:	assertEquals("Next wrong top", (pauseHeight - nextHeight) / 2, mNext.getTop()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAdjustViewBounds, setImageResource, setScaleType, setLayoutParams, setPadding
66:	imageView = new ImageView(mContext); 
67:	imageView.setLayoutParams(new GridView.LayoutParams(45, 45)); 
68:	imageView.setAdjustViewBounds(false); 
69:	imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 
70:	imageView.setPadding(8, 8, 8, 8); 
-
75:	imageView.setImageResource(mThumbIds[position]); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAdjustViewBounds, setImageResource, setBackgroundResource, setLayoutParams
137:	ImageView i = new ImageView(mContext); 
-
139:	i.setImageResource(THUMB_IDS[position]); 
140:	i.setAdjustViewBounds(true); 
141:	i.setLayoutParams(new Gallery.LayoutParams( 
-
143:	i.setBackgroundResource(android.R.drawable.picture_frame); 
Full Snippet Info
8
CodeRank
Examples using Android ImageView setScaleType method:
This code example shows how to use the following methods: setImageBitmap, setScaleType, setLayoutParams, setPadding
84:	ImageView iv = new ImageView(context); 
-
87:	iv.setImageBitmap(photo); 
88:	iv.setScaleType(ScaleType.CENTER); 
89:	iv.setPadding(0, 4, 4, 0); 
90:	iv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageDrawable, setScaleType, setLayoutParams
56:	ImageView i = new ImageView(LayoutAnimation1.this); 
-
60:	i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager())); 
61:	i.setScaleType(ImageView.ScaleType.FIT_CENTER); 
-
63:	i.setLayoutParams(new GridView.LayoutParams(w, w)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageDrawable, setScaleType, setLayoutParams
68:	i = new ImageView(Grid1.this); 
69:	i.setScaleType(ImageView.ScaleType.FIT_CENTER); 
70:	i.setLayoutParams(new GridView.LayoutParams(50, 50)); 
-
76:	i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager())); 
Full Snippet Info
8
CodeRank
Examples using Android ImageView setVisibility method:
This code example shows how to use the following methods: setVisibility, setId, setLayoutParams
79:	mImageView = new ImageView(context); 
-
82:	mImageView.setLayoutParams(imageViewLayoutParams); 
83:	mImageView.setId(INTERNAL_IMAGEVIEW_ID); 
84:	mImageView.setVisibility(View.VISIBLE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setImageBitmap, setVisibility
142:	if (imgView != null && AsyncDrawable.getTask(imgView) == this) { //make sure the ImageView instance has not been reused for another page 
-
144:	imgView.setImageBitmap(result); 
145:	imgView.setVisibility(View.VISIBLE); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setImageDrawable, setVisibility, getVisibility
218:	mIconView.setImageDrawable(showIcon ? icon : null); 
-
220:	if (mIconView.getVisibility() != VISIBLE) { 
221:	mIconView.setVisibility(VISIBLE); 
-
224:	mIconView.setVisibility(GONE); 
Full Snippet Info
8
CodeRank
Examples for other Android ImageView methods:
Related Android ImageView Questions & Answers:
Other Android ImageView Examples
15:	    super.onCreate(savedInstanceState);
16:	    setContentView(R.layout.activity_main);
17:	    ImageView button = (ImageView) findViewById(R.id.image);
18:	    InputStream resource = getResources().openRawResource(R.drawable.dog);
19:	    Bitmap bitmap = BitmapFactory.decodeStream(resource);
-
15:	    super.onCreate(savedInstanceState);
16:	    setContentView(R.layout.activity_main);
17:	    ImageView button = (ImageView) findViewById(R.id.image);
18:	    InputStream resource = getResources().openRawResource(R.drawable.dog);
19:	    Bitmap bitmap = BitmapFactory.decodeStream(resource);

Read More

15:	  private static final int REQUEST_CODE = 1;
16:	  private Bitmap bitmap;
17:	  private ImageView imageView;
18:	
19:	  /** Called when the activity is first created. */
-
22:	    super.onCreate(savedInstanceState);
23:	    setContentView(R.layout.main);
24:	    imageView = (ImageView) findViewById(R.id.result);
25:	  }
26:

Read More

14:	        
15:	        // Imageview to show
16:	        ImageView image = (ImageView) findViewById(R.id.image);
17:	        
18:	        // Image url
-
14:	        
15:	        // Imageview to show
16:	        ImageView image = (ImageView) findViewById(R.id.image);
17:	        
18:	        // Image url

Read More

19:	
20:			ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
21:			imageView.setImageResource(imageAdapter.mThumbIds[position]);
22:		}
23:	
-
19:	
20:			ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
21:			imageView.setImageResource(imageAdapter.mThumbIds[position]);
22:		}
23:

Read More

40:		 * */
41:		private class LoadProfileImage extends AsyncTask<String, Void, Bitmap> {
42:			ImageView bmImage;
43:	
44:			public LoadProfileImage(ImageView bmImage) {
-
42:			ImageView bmImage;
43:	
44:			public LoadProfileImage(ImageView bmImage) {
45:				this.bmImage = bmImage;
46:			}

Read More

20:	    // create a new ImageView for each item referenced by the Adapter
21:	    public View getView(int position, View convertView, ViewGroup parent) {
22:	        ImageView imageView;
23:	        if (convertView == null) {  // if it's not recycled, initialize some attributes
24:	            imageView = new ImageView(mContext);
-
22:	        ImageView imageView;
23:	        if (convertView == null) {  // if it's not recycled, initialize some attributes
24:	            imageView = new ImageView(mContext);
25:	            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
26:	            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
-
27:	            imageView.setPadding(8, 8, 8, 8);
28:	        } else {
29:	            imageView = (ImageView) convertView;
30:	        }
31:

Read More

ImageView Class Overview
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 pr...
Methods
  • getDrawable
    Return the view's drawable, or null if no drawable has been assigned.
  • setAdjustViewBounds
    Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.
  • setAlpha
    This method was deprecated in API level 16. use #setImageAlpha(int) instead
  • setImageURI
    Sets the content of this ImageView to the specified Uri.
  • setMaxHeight
    An optional argument to supply a maximum height for this view.
  • setMaxWidth
    An optional argument to supply a maximum width for this view.
  • setScaleType
    Controls how the image should be resized or moved to match the size of this ImageView.