ImageView getDrawable - top ranked examples from Open Source projects

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

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: layout, getDrawable, setImageMatrix
		scheduleControlTimeout(); 
	} 
 
	private void computeBaseMatrix() 
	{ 
		Drawable d = imageView.getDrawable();
		baseMatrix.reset();
 
		if (d != null) {
			// The base matrix is the matrix that displays the entire image bitmap. 
			// It orients the image when orientation is set and scales in X and Y independently,  
			// so that src matches dst exactly. 
			// This may change the aspect ratio of the src. 
			Rect r = new Rect();
			getDrawingRect(r);
			int intrinsicWidth = d.getIntrinsicWidth();
			int intrinsicHeight = d.getIntrinsicHeight();
			int dwidth = intrinsicWidth;
			int dheight = intrinsicHeight;
 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
                + mPause.getPaddingTop() + mPause.getPaddingBottom(),
                mPause.getBackground().getMinimumHeight());
        int prevHeight = Math.max(mPrev.getDrawable().getIntrinsicHeight() + mPrev.getPaddingTop()
                + mPrev.getPaddingBottom(),
                mPrev.getBackground().getMinimumHeight());
        int nextHeight = Math.max(mNext.getDrawable().getIntrinsicHeight() + mNext.getPaddingTop()
                + mNext.getPaddingBottom(),
                mNext.getBackground().getMinimumHeight());
        assertEquals("Layout incorrect height", pauseHeight, mLayout.getHeight()); 
        assertEquals("Pause incorrect height", pauseHeight, mPause.getHeight()); 
        assertEquals("Prev incorrect height", prevHeight, mPrev.getHeight()); 
        assertEquals("Next incorrect height", nextHeight, mNext.getHeight()); 
        assertEquals("Pause wrong top", 0, mPause.getTop()); 
        assertEquals("Prev wrong top", (pauseHeight - prevHeight) / 2, mPrev.getTop());
        assertEquals("Next wrong top", (pauseHeight - nextHeight) / 2, mNext.getTop());
        assertEquals("CurrentTime wrong bottom",  pauseHeight, mCurrentTime.getBottom());
        assertEquals("TotalTime wrong bottom",  pauseHeight, mTotalTime.getBottom());
        assertTrue("CurrentTime too tall", mCurrentTime.getTop() > 0);
        assertTrue("TotalTime too tall", mTotalTime.getTop() > 0);
    } 
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: getDrawable, setImageDrawable
   * Create or update the drawable on the target {@link ImageView} to display the supplied bitmap 
   * image. 
   */ 
  static void setBitmap(ImageView target, Context context, Bitmap bitmap,
      Picasso.LoadedFrom loadedFrom, boolean noFade, boolean debugging) {
    Drawable placeholder = target.getDrawable();
    PicassoDrawable drawable =
        new PicassoDrawable(context, placeholder, bitmap, loadedFrom, noFade, debugging);
    target.setImageDrawable(drawable);
  } 
 
  /** 
   * Create or update the drawable on the target {@link ImageView} to display the supplied 
   * placeholder image. 
   */ 
  static void setPlaceholder(ImageView target, int placeholderResId, Drawable placeholderDrawable) {
    if (placeholderResId != 0) {
      target.setImageResource(placeholderResId);
    } else { 
      target.setImageDrawable(placeholderDrawable);
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: setLayoutParams, getDrawable, setImageResource, setScaleType
     } 
 
     public View getView(int position, View convertView, ViewGroup parent) {
 
      //Use this code if you want to load from resources 
         ImageView i = new ImageView(mContext);
         i.setImageResource(mImageIds[position]);
         i.setLayoutParams(new CoverFlow.LayoutParams(130, 130));
         i.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
          
         //Make sure we set anti-aliasing otherwise we get jaggies 
         BitmapDrawable drawable = (BitmapDrawable) i.getDrawable();
         drawable.setAntiAlias(true);
         return i;
       
      //return mImages[position]; 
     } 
   /** Returns the size (0.0f to 1.0f) of the views  
      * depending on the 'offset' to the center. */  
      public float getScale(boolean focused, int offset) { 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDrawable
    MmsDatabase.slideResolver.execute(new Runnable() {
      @Override 
      public void run() { 
        final Bitmap bitmap         = getThumbnail(maxWidth, maxHeight);
        final ImageView destination = weakImageView.get();
        if (destination != null && destination.getDrawable() == temporaryDrawable) {
          handler.post(new Runnable() {
            @Override 
            public void run() { 
              setThumbnailOn(destination, bitmap, false);
            } 
          }); 
        } 
      } 
    }); 
  } 
 
  private void setThumbnailOn(ImageView imageView, Bitmap thumbnail, boolean fromMemory) {
    if (fromMemory) {
      imageView.setImageBitmap(thumbnail);
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setOnClickListener, getDrawable, setImageBitmap
		NMEWebView.view = NMEWebView.webView;
		 
		if(withPopup) {
			webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
			 
			ImageView closeImageView = new ImageView(GameActivity.getContext());
			closeImageView.setOnClickListener(new View.OnClickListener() {
				@Override 
				public void onClick(View v) {
					NMEWebView.APIDestroy(); 
				} 
			}); 
			 
			DisplayMetrics metrics = new DisplayMetrics();
			GameActivity.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
			// Log.d("NME", ""+ metrics.densityDpi); 
			 
			String dpi = "mdpi"; // DisplayMetrics.DENSITY_DEFAULT || DisplayMetrics.DENSITY_MEDIUM
			if(metrics.densityDpi == DisplayMetrics.DENSITY_LOW) {
				dpi = "ldpi";

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getHeight, getWidth, getDrawable
		colorView.setBackgroundColor(color);
		 
		// setup the click listener 
		colormap.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				BitmapDrawable bd = (BitmapDrawable) colormap.getDrawable();
				Bitmap bitmap = bd.getBitmap();
 
				// get the color value.  
				// scale the touch location 
				int x = (int) ((event.getX()-15) * bitmap.getWidth() / (colormap.getWidth()-30));
				int y = (int) ((event.getY()-15) * bitmap.getHeight() / (colormap.getHeight()-30));
 
				if (x >= bitmap.getWidth())
					x = (int) bitmap.getWidth() - 1;
				if (x < 0)
					x = 0;
 
				if (y >= bitmap.getHeight())
					y = (int) bitmap.getHeight() - 1;
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDrawable, setImageDrawable
 
            StateListDrawable states = new StateListDrawable();
            states.addState(new int[] {android.R.attr.state_pressed}, outlineD);
            states.addState(new int[] {android.R.attr.state_focused}, outlineD);
            states.addState(new int[] {}, originalD);
            v.setImageDrawable(states);
        } 
    } 
 
    /** 
     * Invalidates the pressed/focused states. 
     */ 
    void invalidatePressedFocusedStates(ImageView v) {
        mStatesUpdated = false;
        if (v != null) {
            v.invalidate();
        } 
    } 
 
    /** 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getResources, getDrawable, setImageDrawable
	} 
 
 
	private void setImageBitmapWithFade(final Bitmap bitmap, final ImageView imageView)
	{ 
		Resources resources = imageView.getResources();
		BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap);
		setImageDrawableWithFade(bitmapDrawable, imageView);
	} 
 
 
	private void setImageDrawableWithFade(final Drawable drawable, final ImageView imageView)
	{ 
		Drawable currentDrawable = imageView.getDrawable();
		if(currentDrawable != null)
		{ 
			Drawable[] drawableArray = new Drawable[2];
			drawableArray[0] = currentDrawable;
			drawableArray[1] = drawable;
			TransitionDrawable transitionDrawable = new TransitionDrawable(drawableArray);

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

Related ImageView getDrawable Questions & Answers:

getDrawable Method Overview
Return the view's drawable, or null if no drawable has been assigned.
See Code Examples for other Android ImageView Methods: