Java Code Examples for android.widget.ImageView.ScaleType

The following are Jave code examples for showing how to use ScaleType of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ucar-weex-core   File: WXImageTest.java   View Source Code Vote up 6 votes
@Test
public void testSetResizeMode() throws Exception {

  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setResizeMode("cover");
  ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
  assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);

}
 
Example 2
Project: UiLib   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
private static boolean isSupportedScaleType(ImageView.ScaleType scaleType) {
    if(null == scaleType) {
        return false;
    } else {
        switch(scaleType.ordinal()) {
            case 1:
                throw new IllegalArgumentException(scaleType.name() + " is not supported in PhotoView");
            default:
                return true;
        }
    }
}
 
Example 3
Project: KUtils-master   File: BGABannerUtil.java   View Source Code Vote up 6 votes
public static ImageView getItemImageView(Context context, @DrawableRes int placeholderResId, ImageView.ScaleType scaleType) {
    ImageView imageView = new ImageView(context);
    imageView.setImageResource(placeholderResId);
    imageView.setClickable(true);
    imageView.setScaleType(scaleType);
    return imageView;
}
 
Example 4
Project: ucar-weex-core   File: WXImageTest.java   View Source Code Vote up 6 votes
@Test
public void testSetResize() throws Exception {
  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setResize("cover");
  ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
  assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);
}
 
Example 5
Project: GravityBox   File: KeyButtonContainer.java   View Source Code Vote up 5 votes
public void setScaleType(ImageView.ScaleType scaleType) {
    mKeyButtonView.setScaleType(scaleType);
}
 
Example 6
Project: GitHub   File: ANRequest.java   View Source Code Vote up 5 votes
public ImageView.ScaleType getScaleType() {
    return mScaleType;
}
 
Example 7
Project: GitHub   File: ImageOptions.java   View Source Code Vote up 5 votes
public ImageView.ScaleType getImageScaleType() {
    return imageScaleType;
}
 
Example 8
Project: GitHub   File: ANRequest.java   View Source Code Vote up 5 votes
public T setImageScaleType(ImageView.ScaleType imageScaleType) {
    mScaleType = imageScaleType;
    return (T) this;
}
 
Example 9
Project: GitHub   File: ImageOptions.java   View Source Code Vote up 5 votes
public Builder setImageScaleType(ImageView.ScaleType imageScaleType) {
    options.imageScaleType = imageScaleType;
    return this;
}
 
Example 10
Project: easyfilemanager   File: ImageUtils.java   View Source Code Vote up 5 votes
public static Bitmap getImageThumbnail(String path, int mMaxWidth, int mMaxHeight){
    Bitmap.Config mDecodeConfig = Bitmap.Config.RGB_565;
    ImageView.ScaleType mScaleType = ImageView.ScaleType.CENTER_CROP;

    File bitmapFile = new File(path);
    Bitmap bitmap = null;

    if (!bitmapFile.exists() || !bitmapFile.isFile()) {
        return bitmap;
    }

    BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
    decodeOptions.inInputShareable = true;
    decodeOptions.inPurgeable = true;
    decodeOptions.inPreferredConfig = mDecodeConfig;
    if (mMaxWidth == 0 && mMaxHeight == 0) {

        bitmap = BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
    } else {
        // If we have to resize this image, first get the natural bounds.
        decodeOptions.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
        int actualWidth = decodeOptions.outWidth;
        int actualHeight = decodeOptions.outHeight;

        // Then compute the dimensions we would ideally like to decode to.
        int desiredWidth = getResizedDimension(mMaxWidth, mMaxHeight,
                actualWidth, actualHeight, mScaleType);
        int desiredHeight = getResizedDimension(mMaxHeight, mMaxWidth,
                actualHeight, actualWidth, mScaleType);

        // Decode to the nearest power of two scaling factor.
        decodeOptions.inJustDecodeBounds = false;
        decodeOptions.inSampleSize = ImageUtils.findBestSampleSize(actualWidth, actualHeight, desiredWidth, desiredHeight);
        Bitmap tempBitmap = BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
        // If necessary, scale down to the maximal acceptable size.
        if (tempBitmap != null
                && (tempBitmap.getWidth() > desiredWidth || tempBitmap.getHeight() > desiredHeight)) {
            bitmap = Bitmap.createScaledBitmap(tempBitmap, desiredWidth,
                    desiredHeight, true);
            tempBitmap.recycle();
        } else {
            bitmap = tempBitmap;
        }

    }
    return bitmap;
}
 
Example 11
Project: TPlayer   File: BitmapCallback.java   View Source Code Vote up 5 votes
public BitmapCallback(int maxWidth, int maxHeight, Bitmap.Config decodeConfig, ImageView.ScaleType scaleType) {
    convert = new BitmapConvert(maxWidth, maxHeight, decodeConfig, scaleType);
}
 
Example 12
Project: weex-3d-map   File: WXImageTest.java   View Source Code Vote up 4 votes
@Test
public void testSetProperty() throws Exception {

  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setProperty(Constants.Name.RESIZE_MODE, "cover");
  ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
  assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);


}
 
Example 13
Project: ClouldReader   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Return the current scale type in use by the ImageView.
 *
 * @return current ImageView.ScaleType
 */
ImageView.ScaleType getScaleType();
 
Example 14
Project: GitHub   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Controls how the image should be resized or moved to match the size of
 * the ImageView. Any scaling or panning will happen within the confines of
 * this {@link ImageView.ScaleType}.
 *
 * @param scaleType - The desired scaling mode.
 */
void setScaleType(ImageView.ScaleType scaleType);
 
Example 15
Project: Tribe   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Controls how the image should be resized or moved to match the size of
 * the ImageView. Any scaling or panning will happen within the confines of
 * this {@link ImageView.ScaleType}.
 *
 * @param scaleType - The desired scaling mode.
 */
void setScaleType(ImageView.ScaleType scaleType);
 
Example 16
Project: GCSApp   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
Example 17
Project: Sega   File: IBuilder.java   View Source Code Vote up 3 votes
/**
 * Set the scale type for the header ImageView.
 *
 * @param scaleType the scale type for the header ImageView
 * @return this
 */
MaterialStyledDialog.Builder setHeaderScaleType(ImageView.ScaleType scaleType);
 
Example 18
Project: Tribe   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
Example 19
Project: KTalk   File: IPhotoView.java   View Source Code Vote up 3 votes
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
Example 20
Project: UiLib   File: IPhotoView.java   View Source Code Vote up 1 votes
void setScaleType(ImageView.ScaleType var1);