मैं व्यावहारिक बुकशेल्फ से टच V2 उदाहरण का उपयोग एक लोड बिटमैप छवि के साथ एक RelativeLayout है गैलरी से छवि। गतिविधि पर परिणाम छवि RelativeLayout में एक बिटमैप के रूप में भरी हुई है:view.getDrawingCache() केवल एक बार काम करता है
public void getPictureFromFile(Uri targetUri){
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scale(getContentResolver()
.openInputStream(targetUri));
workinprogress = BitmapFactory.decodeStream(
getContentResolver().openInputStream(targetUri),
null, options);
view.setImageBitmap(workinprogress);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
एक अगला बटन क्लिक करें, मैं का उपयोग कर relativelayout की छवि हड़पने:
thepicture.buildDrawingCache(true);
Bitmap bm = Bitmap.createBitmap(thepicture.getDrawingCache());
प्रक्रिया भयानक काम करता है - पहली छवि के लिए। जब मैं एक और छवि फिर से लोड करता हूं, तो पास बिटमैप मूल के समान ही होता है। मैंने getpicture.invalidate() और theictict.resetDrawableState() को getDrawingCache() से पहले कोशिश की है, लेकिन न ही नई लोड की गई तस्वीर में छवि को अपडेट करना प्रतीत होता है, हालांकि फ्रेम लेआउट सही छवि प्रदर्शित करता है।
क्या कुछ ऐसा है जो मुझे रीफ्रेशिंग ड्राइंग के बारे में समझ में नहीं आता है जिसे मैं दूसरी छवि के लिए लागू करने की आवश्यकता है?
+1 इसने मुझे काम के घंटों को बर्बाद करने से बचाया। अच्छा एक dmytro –
ड्राइंग कैश को सक्षम करने के लिए एक वैकल्पिक विधि के रूप में, आप 'imageView.buildDrawingCache()' को भी कॉल कर सकते हैं, फिर ड्रॉइंग कैश प्राप्त करें, फिर 'imageView.destroyDrawingCache() 'पर कॉल करें। Http://developer.android.com/reference/android/view/View.html#buildDrawingCache() – lilbyrdie
ने नौकरी की, धन्यवाद। –