I\'m using a photo picker intent to choose an image and write it to an application-private file. Most of my important source code is shown below. Once I press a button and p
ImageView will not redraw if "new" URI is the same like old one. "View.invalidate()" will not work. To "force" update you can do:
public void onResume() {
super.onResume();
ImageView myImageView = (ImageView)findViewById(R.id.contact_image);
if (hasImage) {
myImageView.setImageDrawable(null); // <--- added to force redraw of ImageView
myImageView.setImageURI(Uri.fromFile(getFileStreamPath(TEMP_PHOTO_FILE)));
}
}
I had a similar problem where I was using the devices camera to take a picture and then wanting the imageView in the original screen to refresh when I returned to it. The solution was to call View.invalidate() in onResume().
I would suggest this thing solution. After trying lot of solutions i found this one worked for me.
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 1000ms
ivProfilePic.setImageBitmap(bitImage);
}
}, 1000);
invalidate() not worked. Try hack :
imageView.setImageURI(null);
imageView.setImageURI(newUri);
To force redrawing your widget/View just call View.invalidate();
UIView.transition(with: bannerImageView, duration: 0.3, options: [.transitionCrossDissolve], animations: { [weak self] in
self?.exampleImageView.image = newImage
})
Use this func in your view controller