Android ImageView.ScaleType - 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.ScaleType class.

This code example shows how to use the following methods:ordinal
 * Simplify {@linkplain ScaleType ImageView's scale type} to 2 types: {@link #FIT_INSIDE} and {@link #CROP} 
 * 
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com) 
 * @since 1.6.1 
 */ 
public enum ViewScaleType { 
	/** 
	 * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the 
	 * image will be equal to or less the corresponding dimension of the view. 
	 */ 
	FIT_INSIDE,
	/** 
	 * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the 
	 * image will be equal to or larger than the corresponding dimension of the view. 
	 */ 
	CROP;
 
	/** 
	 * Defines scale type of ImageView. 
	 * 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
This code example shows how to use the following methods:toString
		setMatrix(); 
	} 
 
	@Override 
	public void draw(Canvas canvas) {
		Log.w(TAG, "Draw: " + mScaleType.toString());
		if (mBorderWidth > 0) {
			canvas.drawRoundRect(mBorderRect, mCornerRadius, mCornerRadius, mBorderPaint);
			canvas.drawRoundRect(mDrawableRect, Math.max(mCornerRadius - mBorderWidth, 0), Math.max(mCornerRadius - mBorderWidth, 0), mBitmapPaint);
		} else { 
			canvas.drawRoundRect(mDrawableRect, mCornerRadius, mCornerRadius, mBitmapPaint);
		} 
	} 
 
	@Override 
	public int getOpacity() { 
		return PixelFormat.TRANSLUCENT;
	} 
 
	@Override 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
 * ScaleType values 
 * 
 * @author Cyril Mottier 
 * @author kennydude 
 */ 
public class ScaleImageProcessor implements ImageProcessor { 
 
    private int mWidth;
    private int mHeight;
    private ScaleType mScaleType;
    private final Matrix mMatrix = new Matrix();
 
    private final RectF mTempSrc = new RectF();
    private final RectF mTempDst = new RectF();
 
    /** 
     * Create a new ScaleImageProcessor. 
     * 
     * @param width The width of the final surrounding box 
     * @param height The height of the final surrounding box 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
package cm.aptoide.com.nostra13.universalimageloader.core.assist; 
 
import android.widget.ImageView; 
import android.widget.ImageView.ScaleType; 
 
/** 
 * Simplify {@linkplain ScaleType ImageView's scale type} to 2 types: {@link #FIT_INSIDE} and {@link #CROP} 
 *  
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com) 
 */ 
public enum ViewScaleType { 
	/** 
	 * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the 
	 * image will be equal to or less the corresponding dimension of the view. 
	 */ 
	FIT_INSIDE,
	/** 
	 * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the 
	 * image will be equal to or larger than the corresponding dimension of the view. 
	 */ 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
        mMatrix.reset();
 
        final int bWidth = bitmap.getWidth();
        final int bHeight = bitmap.getHeight();
 
        switch (mScaleType) {
 
            case CENTER_CROP: {
                // Center and scale the bitmap so that it entirely fills the 
                // given space. The bitmap ratio remains unchanged 
                float scale;
                float dx = 0, dy = 0;
 
                if (bWidth * mHeight > mWidth * bHeight) {
                    scale = (float) mHeight / (float) bHeight;
                    dx = (mWidth - bWidth * scale) * 0.5f;
                } else { 
                    scale = (float) mWidth / (float) bWidth;
                    dy = (mHeight - bHeight * scale) * 0.5f;
                } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
 
/** 
 * Methods that are hidden inside the ImageView Android implementation. 
 * @author Roman Mazur (Stanfy - http://www.stanfy.com) 
 */ 
final class ImageViewHiddenMethods { 
 
  /** Temp objects. */ 
  private static final RectF SRC_RECT = new RectF(), DST_RECT = new RectF();
 
  private ImageViewHiddenMethods() { /* hide */ } 
 
  private static Matrix.ScaleToFit scaleTypeToScaleToFit(final ScaleType st)  {
    switch (st) {
    case FIT_XY: return Matrix.ScaleToFit.FILL;
    case FIT_START: return Matrix.ScaleToFit.START;
    case FIT_CENTER: return Matrix.ScaleToFit.CENTER;
    case FIT_END: return Matrix.ScaleToFit.END;
    default: 
      return null; 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
		try { 
 
			InputStream is = (InputStream) fetch(url);
			BitmapDrawable d = (BitmapDrawable) ScaleDrawable.createFromStream(
					is, "src");
			d.setGravity(ScaleType.CENTER.ordinal());
			MyImageView iv = new MyImageView(context, url, txt);
			iv.setImageDrawable(d);
			return iv;
		} catch (MalformedURLException e) {
			e.printStackTrace();
			return null; 
		} catch (IOException e) {
			e.printStackTrace();
			return null; 
		} 
	} 
 
	private static Object fetch(String address) throws MalformedURLException,
			IOException { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
 * be one of the ScaleType values 
 *  
 * @author Cyril Mottier 
 * @author kennydude 
 */ 
public class ScaleImageProcessor implements ImageProcessor { 
 
    private int mWidth;
    private int mHeight;
    private ScaleType mScaleType;
    private final Matrix mMatrix = new Matrix();
 
    private final RectF mTempSrc = new RectF();
    private final RectF mTempDst = new RectF();
 
    /** 
     * Create a new ScaleImageProcessor. 
     *  
     * @param width The width of the final surrounding box 
     * @param height The height of the final surrounding box 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ordinal
        mMatrix.reset();
 
        final int bWidth = bitmap.getWidth();
        final int bHeight = bitmap.getHeight();
 
        switch (mScaleType) {
 
            case CENTER_CROP: {
                // Center and scale the bitmap so that it entirely fills the 
                // given space. The bitmap ratio remains unchanged 
                float scale;
                float dx = 0, dy = 0;
 
                if (bWidth * mHeight > mWidth * bHeight) {
                    scale = (float) mHeight / (float) bHeight;
                    dx = (mWidth - bWidth * scale) * 0.5f;
                } else { 
                    scale = (float) mWidth / (float) bWidth;
                    dy = (mHeight - bHeight * scale) * 0.5f;
                } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android ImageView.ScaleType Questions & Answers:

See Code Examples for Android ImageView.ScaleType Methods: