问题
I am using: https://github.com/jasonpolites/gesture-imageview
on load of the app, it has a placeholder image in a GestureImageView that pinch/zooms appropriately. I have a button that when clicks fires a camera intent, saves the file, and then I wish to set that image to be the source bitmap used in the gestureimageview.
GestureImageView imageView = (GestureImageView) findViewById(R.id.imageViewOne);
ContentResolver cr = getContentResolver(); getContentResolver().notifyChange(imageUriOne, null); try { Bitmap mybitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, imageUriOne); imageView.setImageBitmap(mybitmap);
}
For a normal imageview, that works. But for the GestureImageView, the image stays as the original once returned from the camera intent, and if touched disappears.
To check it's not the bitmap that's the problem, I tried
int idTwo=getResources().getIdentifier("com.jazz.test1:drawable/second_photo", null, null);
imageView.setImageResource(idTwo);
I.e. set the imageview to an existing resource, but this has the same problem.
If I call that setImageResource code before the intent, it does work.
Any ideas how to debug? There are no errors in the logs.
回答1:
Resolution is here:
https://github.com/jasonpolites/gesture-imageview/issues/21
- hadn't noticed it when I initially looked at the github issues.
回答2:
You have to replace your initMethod function. With this code it will work properly (GestureImageView.java file in com.polites.android package).
protected void initImage() {
if (this.drawable != null) {
this.drawable.setAlpha(alpha);
this.drawable.setFilterBitmap(true);
if (colorFilter != null) {
this.drawable.setColorFilter(colorFilter);
}
// Keppel.Cao
layout = false;
startingScale = -1.0f;
}
if (!layout) {
requestLayout();
// Keppel.Cao
// redraw();
reset();
}
}
Like Dave said. More you can find here Issue 21
来源:https://stackoverflow.com/questions/13866950/gestureimageview-goes-blank-when-trying-to-set-bitmap-from-camera-programaticall