本文整理汇总了Java中android.widget.ImageView.getScaleType方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.getScaleType方法的具体用法?Java ImageView.getScaleType怎么用?Java ImageView.getScaleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.getScaleType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSuccessDrawable4Callback
import android.widget.ImageView; //导入方法依赖的package包/类
private void setSuccessDrawable4Callback(final Drawable drawable) {
final ImageView view = viewRef.get();
if (view != null) {
view.setScaleType(options.getImageScaleType());
if (drawable instanceof GifDrawable) {
if (view.getScaleType() == ImageView.ScaleType.CENTER) {
view.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (options.getAnimation() != null) {
ImageAnimationHelper.animationDisplay(view, drawable, options.getAnimation());
} else if (options.isFadeIn()) {
ImageAnimationHelper.fadeInDisplay(view, drawable);
} else {
view.setImageDrawable(drawable);
}
}
}
示例2: Builder
import android.widget.ImageView; //导入方法依赖的package包/类
public Builder(ImageView imageView) {
viewRef = new WeakReference<>(imageView);
if (imageView.getScaleType() != ImageView.ScaleType.MATRIX) {
throw new IllegalStateException("the image scaleType must be ScaleType.MATRIX");
}
Drawable d = imageView.getDrawable();
if (d != null) {
animCenterX = d.getIntrinsicWidth() / 2;
animCenterY = d.getIntrinsicHeight() / 2;
}
Matrix matrix = new Matrix(imageView.getImageMatrix());
fromDegrees = toDegrees = MatrixUtils.getMatrixAngle(matrix);
fromScaleX = toScaleX = getMatrixScaleX(matrix);
fromScaleY = toScaleY = getMatrixScaleY(matrix);
float[] txty = calculateTxTy();
fromTranslateX = toTranslateX = txty[0];
fromTranslateY = toTranslateY = txty[1];
}
示例3: setupBitmap
import android.widget.ImageView; //导入方法依赖的package包/类
private void setupBitmap(ImageView imageView, float width, float height) {
Drawable drawable = imageView.getDrawable();
if (drawable == null) {
return;
}
try {
bitmap = (drawable instanceof BitmapDrawable) ?
((BitmapDrawable) drawable).getBitmap() :
Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
} catch (Exception e) {
e.printStackTrace();
}
if (bitmap == null) {
imageView.invalidate();
return;
}
paint = new Paint(ANTI_ALIAS_FLAG);
bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setShader(bitmapShader);
if (imageView.getScaleType() != ImageView.ScaleType.CENTER_CROP && imageView.getScaleType() != ImageView.ScaleType.FIT_XY) {
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
bitmapShader.setLocalMatrix(setUpScaleType(bitmap, imageView, width, height));
imageView.invalidate();
}
示例4: checkImageViewScaleType
import android.widget.ImageView; //导入方法依赖的package包/类
private void checkImageViewScaleType() {
ImageView imageView = getImageView();
/**
* PhotoView's getScaleType() will just divert to this.getScaleType() so
* only call if we're not attached to a PhotoView.
*/
if (null != imageView && !(imageView instanceof PhotoView)) {
if (imageView.getScaleType() != ScaleType.MATRIX) {
throw new IllegalStateException(
"The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
}
}
}
示例5: into
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
* the view, and frees any resources Glide may have previously loaded into the view so they may be
* reused.
*
* @see RequestManager#clear(Target)
*
* @param view The view to cancel previous loads for and load the new resource into.
* @return The
* {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
*/
public Target<TranscodeType> into(ImageView view) {
Util.assertMainThread();
Preconditions.checkNotNull(view);
if (!requestOptions.isTransformationSet()
&& requestOptions.isTransformationAllowed()
&& view.getScaleType() != null) {
if (requestOptions.isLocked()) {
requestOptions = requestOptions.clone();
}
switch (view.getScaleType()) {
case CENTER_CROP:
requestOptions.optionalCenterCrop();
break;
case CENTER_INSIDE:
requestOptions.optionalCenterInside();
break;
case FIT_CENTER:
case FIT_START:
case FIT_END:
requestOptions.optionalFitCenter();
break;
case FIT_XY:
requestOptions.optionalCenterInside();
break;
case CENTER:
case MATRIX:
default:
// Do nothing.
}
}
return into(context.buildImageViewTarget(view, transcodeClass));
}
示例6: into
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
* the view, and frees any resources Glide may have previously loaded into the view so they may be
* reused.
*
* @see RequestManager#clear(Target)
*
* @param view The view to cancel previous loads for and load the new resource into.
* @return The
* {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
*/
public ViewTarget<ImageView, TranscodeType> into(ImageView view) {
Util.assertMainThread();
Preconditions.checkNotNull(view);
RequestOptions requestOptions = this.requestOptions;
if (!requestOptions.isTransformationSet()
&& requestOptions.isTransformationAllowed()
&& view.getScaleType() != null) {
// Clone in this method so that if we use this RequestBuilder to load into a View and then
// into a different target, we don't retain the transformation applied based on the previous
// View's scale type.
switch (view.getScaleType()) {
case CENTER_CROP:
requestOptions = requestOptions.clone().optionalCenterCrop();
break;
case CENTER_INSIDE:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case FIT_CENTER:
case FIT_START:
case FIT_END:
requestOptions = requestOptions.clone().optionalFitCenter();
break;
case FIT_XY:
requestOptions = requestOptions.clone().optionalCenterInside();
break;
case CENTER:
case MATRIX:
default:
// Do nothing.
}
}
return into(
glideContext.buildImageViewTarget(view, transcodeClass),
/*targetListener=*/ null,
requestOptions);
}
示例7: checkImageViewScaleType
import android.widget.ImageView; //导入方法依赖的package包/类
private void checkImageViewScaleType() {
ImageView imageView = getImageView();
/**
* PhotoView's getScaleType() will just divert to this.getScaleType() so
* only call if we're not attached to a PhotoView.
*/
if (null != imageView && !(imageView instanceof PhotoView)) {
if (imageView.getScaleType() != ScaleType.MATRIX) {
throw new IllegalStateException("The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
}
}
}
示例8: checkImageViewScaleType
import android.widget.ImageView; //导入方法依赖的package包/类
private void checkImageViewScaleType() {
ImageView imageView = getImageView();
/**
* PhotoView's getScaleType() will just divert to this.getScaleType() so
* only call if we're not attached to a PhotoView.
*/
if (null != imageView && !(imageView instanceof EasePhotoView)) {
if (imageView.getScaleType() != ScaleType.MATRIX) {
throw new IllegalStateException(
"The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
}
}
}
示例9: setUpScaleType
import android.widget.ImageView; //导入方法依赖的package包/类
private Matrix setUpScaleType(Bitmap bitmap, ImageView iv, float width, float height) {
float scaleX = 1, scaleY = 1, dx = 0, dy = 0;
Matrix shaderMatrix = new Matrix();
if (bitmap == null) {
return null;
}
shaderMatrix.set(null);
if (iv.getScaleType() == ImageView.ScaleType.CENTER_CROP) {
if (width != bitmap.getWidth()) {
scaleX = width / bitmap.getWidth();
}
if (scaleX * bitmap.getHeight() < height) {
scaleX = height / bitmap.getHeight();
}
dy = (height - bitmap.getHeight() * scaleX) * 0.5f;
dx = (width - bitmap.getWidth() * scaleX) * 0.5f;
shaderMatrix.setScale(scaleX, scaleX);
} else {
scaleX = width / bitmap.getWidth();
scaleY = height / bitmap.getHeight();
dy = (height - bitmap.getHeight() * scaleY) * 0.5f;
dx = (width - bitmap.getWidth() * scaleX) * 0.5f;
shaderMatrix.setScale(scaleX, scaleY);
}
shaderMatrix.postTranslate(dx + 0.5f, dy + 0.5f);
return shaderMatrix;
}
示例10: checkImageViewScaleType
import android.widget.ImageView; //导入方法依赖的package包/类
private void checkImageViewScaleType() {
ImageView imageView = getImageView();
/**
* PhotoView's getScaleType() will just divert to this.getScaleType() so
* only call if we're not attached to a PhotoView.
*/
if (null != imageView && !(imageView instanceof EasePhotoView)) {
if (imageView.getScaleType() != ScaleType.MATRIX) {
throw new IllegalStateException(
"The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
}
}
}
示例11: onCaptureSharedElementSnapshot
import android.widget.ImageView; //导入方法依赖的package包/类
public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {
Bitmap bitmap;
if (sharedElement instanceof ImageView) {
ImageView imageView = (ImageView) sharedElement;
Drawable d = imageView.getDrawable();
Drawable bg = imageView.getBackground();
if (d != null && bg == null) {
bitmap = createDrawableBitmap(d);
if (bitmap != null) {
Bundle bundle = new Bundle();
bundle.putParcelable(BUNDLE_SNAPSHOT_BITMAP, bitmap);
bundle.putString(BUNDLE_SNAPSHOT_IMAGE_SCALETYPE, imageView.getScaleType().toString());
if (imageView.getScaleType() != ScaleType.MATRIX) {
return bundle;
}
float[] values = new float[9];
imageView.getImageMatrix().getValues(values);
bundle.putFloatArray(BUNDLE_SNAPSHOT_IMAGE_MATRIX, values);
return bundle;
}
}
}
int bitmapWidth = Math.round(screenBounds.width());
int bitmapHeight = Math.round(screenBounds.height());
bitmap = null;
if (bitmapWidth > 0 && bitmapHeight > 0) {
float scale = Math.min(1.0f, ((float) MAX_IMAGE_SIZE) / ((float) (bitmapWidth * bitmapHeight)));
bitmapWidth = (int) (((float) bitmapWidth) * scale);
bitmapHeight = (int) (((float) bitmapHeight) * scale);
if (this.mTempMatrix == null) {
this.mTempMatrix = new Matrix();
}
this.mTempMatrix.set(viewToGlobalMatrix);
this.mTempMatrix.postTranslate(-screenBounds.left, -screenBounds.top);
this.mTempMatrix.postScale(scale, scale);
bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.concat(this.mTempMatrix);
sharedElement.draw(canvas);
}
return bitmap;
}