Android ImageView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ImageView class.

This code example shows how to use the following methods: getVisibility, setImageDrawable, setVisibility
        if (mIconView == null) {
            insertIconView(); 
        } 
 
        if (icon != null || mPreserveIconSpacing) {
            mIconView.setImageDrawable(showIcon ? icon : null);
 
            if (mIconView.getVisibility() != VISIBLE) {
                mIconView.setVisibility(VISIBLE);
            } 
        } else { 
            mIconView.setVisibility(GONE);
        } 
    } 
 
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mIconView != null && mPreserveIconSpacing) {
            // Enforce minimum icon spacing 
            ViewGroup.LayoutParams lp = getLayoutParams();
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setImageDrawable, setImageResource, setVisibility
        if (mMobileType != null) {
            mMobileType.setImageDrawable(null);
        } 
 
        if(mAirplane != null) {
            mAirplane.setImageDrawable(null);
        } 
 
        apply(); 
    } 
 
    // Run after each indicator change. 
    private void apply() { 
        if (mWifiGroup == null) return;
 
        if (mWifiVisible) {
            mWifi.setImageResource(mWifiStrengthId);
            mWifiActivity.setImageResource(mWifiActivityId);
 
            mWifiGroup.setContentDescription(mWifiDescription);

10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setPadding, setImageBitmap, setScaleType
This code example shows how to use the following methods: getHeight, getLayoutParams
	 */ 
	@Override 
	public int getHeight() { 
		ImageView imageView = imageViewRef.get();
		if (imageView != null) {
			final ViewGroup.LayoutParams params = imageView.getLayoutParams();
			int height = 0;
			if (checkActualViewSize && params != null && params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
				height = imageView.getHeight(); // Get actual image height
			} 
			if (height <= 0 && params != null) height = params.height; // Get layout height parameter
			if (height <= 0) height = getImageViewFieldValue(imageView, "mMaxHeight"); // Check maxHeight parameter
			return height;
		} 
		return 0; 
	} 
 
	@Override 
	public ViewScaleType getScaleType() { 
		ImageView imageView = imageViewRef.get();
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setImageResource, setScaleType
        return position;
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);
        i.setImageResource(mImageIds[position]);
        i.setScaleType(ScaleType.CENTER_INSIDE);
        return i;
    } 
} 
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getTag, invalidate, setImageBitmap
    return(result);
  } 
 
  @Override 
  protected void onPostExecute(Bitmap bitmap) {
      if (path.equals(image.getTag())) {
        image.setImageBitmap(bitmap);
        image.invalidate();
      } 
       
      if (ex!=null) {
        Log.e("ImageLoadTask", "Exception loading image", ex);
      } 
  } 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getTag, setTag, getDrawable, setImageDrawable
    } 
 
    // protected for testing purposes 
    protected void loadBitmapAsynchronously(T octo, ImageView thumbImageView,
        String tempThumbnailImageFileName) {
        if (thumbImageView.getTag() != null
            && thumbImageView.getTag().equals(tempThumbnailImageFileName)) {
            return; 
        } 
 
        if (cancelPotentialWork(tempThumbnailImageFileName, thumbImageView)) {
            final BitmapWorkerTask task = new BitmapWorkerTask(thumbImageView,
                octo);
            task.fileName = tempThumbnailImageFileName;
            final AsyncDrawable asyncDrawable = new AsyncDrawable(getContext()
                .getResources(), task);
            thumbImageView.setImageDrawable(asyncDrawable);
            thumbImageView.setTag(tempThumbnailImageFileName);
            int width = Math.round(convertDpToPixel(IMG_WIDTH, getContext()));
            int height = width;

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setBackgroundResource, setLayoutParams, setImageResource, setScaleType
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {
                convertView = new ImageView(mContext);
 
                imageView = (ImageView) convertView;
                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                imageView.setLayoutParams(new Gallery.LayoutParams(
                        (int) (ITEM_WIDTH * mDensity + 0.5f),
                        (int) (ITEM_HEIGHT * mDensity + 0.5f)));
             
                // The preferred Gallery item background 
                imageView.setBackgroundResource(mGalleryItemBackground);
            } else { 
                imageView = (ImageView) convertView;
            } 
 
            imageView.setImageResource(mImageIds[position]);

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setPadding, setAdjustViewBounds, setImageResource, setScaleType
This code example shows how to use the following methods: clearAnimation, getAnimation, getContext, getTag, setTag
 
    ImageView view = getView();
    if (view == null)
      return; 
 
    if (!equals(view.getTag()))
      return; 
 
    view.setTag(null);
    if (result != null) {
      if (fadeIn && view.getAnimation() == null)
        view.startAnimation(AnimationUtils.loadAnimation(view.getContext(),
            android.R.anim.fade_in));
      view.setImageBitmap(result);
    } else { 
      view.setImageDrawable(null);
      view.clearAnimation();
    } 
  } 
} 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

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

See Code Examples for Android ImageView Methods: