當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.getScaleType方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:ImageLoader.java

示例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];

}
 
開發者ID:xyzxqs,項目名稱:XphotoView,代碼行數:23,代碼來源:ImageMatrixAnimator.java

示例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();
}
 
開發者ID:akshay2211,項目名稱:Oblique,代碼行數:27,代碼來源:ObliqueView.java

示例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");
		}
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:PhotoViewAttacher.java

示例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));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:46,代碼來源:RequestBuilder.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:50,代碼來源:RequestBuilder.java

示例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");
        }
    }
}
 
開發者ID:liuke2016,項目名稱:filepicker,代碼行數:14,代碼來源:PhotoViewAttacher.java

示例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");
		}
	}
}
 
開發者ID:turoDog,項目名稱:KTalk,代碼行數:15,代碼來源:PhotoViewAttacher.java

示例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;
}
 
開發者ID:akshay2211,項目名稱:Oblique,代碼行數:28,代碼來源:ObliqueView.java

示例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");
        }
    }
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:15,代碼來源:PhotoViewAttacher.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:43,代碼來源:SharedElementCallback.java


注:本文中的android.widget.ImageView.getScaleType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。