android.widget.ImageView.invalidate()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中android.widget.ImageView.invalidate()方法的一些代码示例,展示了ImageView.invalidate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.invalidate()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:invalidate

ImageView.invalidate介绍

暂无

代码示例

代码示例来源:origin: siyamed/android-shape-imageview

public void invalidate() {
  invalidated = true;
  super.invalidate();
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void invalidate() {
  super.invalidate();
  invalidateParentIfNeeded();
}

代码示例来源:origin: stackoverflow.com

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
  super.onActivityResult(requestCode, resultCode, data);
  switch(requestCode){
    case INTENT_REQUEST_SELECT_IMAGE:
      if(resultCode==Activity.RESULT_OK){
        Uri selectedImageUri = data.getData();
        Log.i(TAG,"selectedImageUri.getPath()"+selectedImageUri.getPath() );
        ImageView imageView = (ImageView) this.findViewById(R.id.ImageView_of_text);
        ((BitmapDrawable)imageView.getDrawable()).getBitmap().recycle();
        imageView.setImageURI(selectedImageUri);
        imageView.invalidate();

      }else{
        //TODO define what to do in case the user canceled OCR or any other event
      }
      break;
    default:
      break;
  }
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void invalidate(int l, int t, int r, int b) {
  super.invalidate(l, t, r, b);
  invalidateParentIfNeeded();
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void invalidate(@NonNull Rect dirty) {
  super.invalidate(dirty);
  invalidateParentIfNeeded();
}

代码示例来源:origin: arimorty/floatingsearchview

public static void setIconColor(ImageView iconHolder, int color) {
  Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
  DrawableCompat.setTint(wrappedDrawable, color);
  iconHolder.setImageDrawable(wrappedDrawable);
  iconHolder.invalidate();
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

public static void animateTransform(@NonNull ImageView imageView, @Nullable Matrix matrix) {
  Drawable drawable = imageView.getDrawable();
  if (drawable == null) {
    return;
  }
  if (matrix == null || drawable.getIntrinsicWidth() == -1
      || drawable.getIntrinsicHeight() == -1) {
    drawable.setBounds(0, 0, imageView.getWidth(), imageView.getHeight());
  } else {
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    Matrix drawMatrix = imageView.getImageMatrix();
    if (drawMatrix.isIdentity()) {
      drawMatrix = new Matrix();
      ReflectionUtils.setFieldValue(imageView, FIELD_DRAW_MATRIX, drawMatrix);
    }
    drawMatrix.set(matrix);
  }
  imageView.invalidate();
}

代码示例来源:origin: akexorcist/Android-RoundCornerProgressBar

private void drawImageIconPadding() {
  if (iconPadding == -1 || iconPadding == 0) {
    ivProgressIcon.setPadding(iconPaddingLeft, iconPaddingTop, iconPaddingRight, iconPaddingBottom);
  } else {
    ivProgressIcon.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
  }
  ivProgressIcon.invalidate();
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
 mAnimRect.left =
   mStartCropWindowRect.left
     + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
 mAnimRect.top =
   mStartCropWindowRect.top
     + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
 mAnimRect.right =
   mStartCropWindowRect.right
     + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
 mAnimRect.bottom =
   mStartCropWindowRect.bottom
     + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
 mCropOverlayView.setCropWindowRect(mAnimRect);
 for (int i = 0; i < mAnimPoints.length; i++) {
  mAnimPoints[i] =
    mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
 }
 mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());
 for (int i = 0; i < mAnimMatrix.length; i++) {
  mAnimMatrix[i] =
    mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
 }
 Matrix m = mImageView.getImageMatrix();
 m.setValues(mAnimMatrix);
 mImageView.setImageMatrix(m);
 mImageView.invalidate();
 mCropOverlayView.invalidate();
}

代码示例来源:origin: lyft/scissors

@Override
public void onAnimationUpdate(@GestureAnimator.AnimationType int animationType, float animationValue) {
  if(animationType == GestureAnimator.ANIMATION_X) {
    position.set(animationValue, position.getY());
    ensureInsideViewport();
  }
  else if(animationType == GestureAnimator.ANIMATION_Y) {
    position.set(position.getX(), animationValue);
    ensureInsideViewport();
  }
  else if(animationType == GestureAnimator.ANIMATION_SCALE) {
    scale = animationValue;
    setLimits();
  }
  imageView.invalidate();
}

代码示例来源:origin: tommybuonomo/dotsindicator

private void refreshDotsColors() {
 if (dots == null) {
  return;
 }
 for (int i = 0; i < dots.size(); i++) {
  ImageView elevationItem = dots.get(i);
  DotsGradientDrawable background = (DotsGradientDrawable) elevationItem.getBackground();
  if (i == viewPager.getCurrentItem() || (progressMode && i < viewPager.getCurrentItem())) {
   background.setColor(selectedDotColor);
  } else {
   background.setColor(dotsColor);
  }
  elevationItem.setBackground(background);
  elevationItem.invalidate();
 }
}

代码示例来源:origin: guolindev/giffun

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
 mAnimRect.left =
   mStartCropWindowRect.left
     + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
 mAnimRect.top =
   mStartCropWindowRect.top
     + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
 mAnimRect.right =
   mStartCropWindowRect.right
     + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
 mAnimRect.bottom =
   mStartCropWindowRect.bottom
     + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
 mCropOverlayView.setCropWindowRect(mAnimRect);
 for (int i = 0; i < mAnimPoints.length; i++) {
  mAnimPoints[i] =
    mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
 }
 mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());
 for (int i = 0; i < mAnimMatrix.length; i++) {
  mAnimMatrix[i] =
    mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
 }
 Matrix m = mImageView.getImageMatrix();
 m.setValues(mAnimMatrix);
 mImageView.setImageMatrix(m);
 mImageView.invalidate();
 mCropOverlayView.invalidate();
}

代码示例来源:origin: baiyuliang/QRobot

public void invalidate() {
  mWeakBitmap = null;
  if (mMaskBitmap != null) { mMaskBitmap.recycle(); }
  super.invalidate();
}

代码示例来源:origin: q422013/IMChat

public void invalidate() {
  mWeakBitmap = null;
  if (mMaskBitmap != null) {
    mMaskBitmap.recycle();
  }
  super.invalidate();
}

代码示例来源:origin: stackoverflow.com

Uri path = result.getParcelableExtra("image");
 if(path != null) {
   ImageView iv = (ImageView) getActivity().findViewById(R.id.myImage);
   iv.setImageURI(path);
   iv.invalidate();
 }

代码示例来源:origin: THEONE10211024/ApiDemos

public void onClick(View view) {
    int mColor = (int) Math.floor(Math.random() * mColors.length);
    wallpaperDrawable.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);
    imageView.setImageDrawable(wallpaperDrawable);
    imageView.invalidate();
  }
});

代码示例来源:origin: huangyz0918/AndroidWM

/**
 * load a bitmap as background image from a ImageView.
 *
 * @param imageView the {@link ImageView} we need to use.
 */
private void backgroundFromImageView(ImageView imageView) {
  imageView.invalidate();
  if (imageView.getDrawable() != null) {
    BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
    backgroundImg = resizeBitmap(drawable.getBitmap(), MAX_IMAGE_SIZE);
  }
}

代码示例来源:origin: huangyz0918/AndroidWM

/**
 * load a bitmap as watermark image from a ImageView.
 *
 * @param imageView the ImageView we need to use.
 */
private void watermarkFromImageView(ImageView imageView) {
  imageView.invalidate();
  BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
  // set the limitation of input bitmap.
  this.image = resizeBitmap(drawable.getBitmap(), MAX_IMAGE_SIZE);
}

代码示例来源:origin: limboemu/limbo

/**
 * Call in UI thread; tell ImageView we've changed
 * 
 * @param v
 *            ImageView displaying bitmap data
 */
void updateView(ImageView v) {
  if (drawable == null)
    drawable = createDrawable();
  v.setImageDrawable(drawable);
  v.invalidate();
}

代码示例来源:origin: zendesk/belvedere

static void internalSetTint(ImageView imageView, int color) {
  if(imageView == null) {
    return;
  }
  Drawable d = DrawableCompat.wrap(imageView.getDrawable());
  if(d != null) {
    DrawableCompat.setTint(d.mutate(), color);
  }
  imageView.invalidate();
}

相关文章

ImageView类方法