0
A
回答
1
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
鏈接引導你如何加載位圖有效especialcy下負載縮小版的話題到內存
在不使用時,您應該回收的位圖。
bitmaps.recycle();
位圖也存儲在從honeycomb開始的堆上。所以當不使用時回收位圖。
http://www.youtube.com/watch?v=_CruQY55HOk。如果遇到內存泄漏,請使用MAT分析器來查找並修復它。該視頻就這個話題進行了討論。它還解釋瞭如何管理內存。
如果要顯示大量的位圖,請使用通用圖像加載程序。使用listview或grdiview來顯示圖像。
https://github.com/nostra13/Android-Universal-Image-Loader。
它基於Lazy List(基於相同原理)。但它有很多其他配置。我寧願使用通用圖像加載程序因爲它給你更多的配置選項。如果downlaod失敗,您可以顯示錯誤圖像。可以顯示圓角的圖像。可以緩存在光盤或內存上。可以壓縮圖像。
在您的自定義適配器構造
File cacheDir = StorageUtils.getOwnCacheDirectory(a, "your folder");
// Get singletone instance of ImageLoader
imageLoader = ImageLoader.getInstance();
// Create configuration for ImageLoader (all options are optional)
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
// You can pass your own memory cache implementation
.discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.enableLogging()
.build();
// Initialize ImageLoader with created configuration. Do it once.
imageLoader.init(config);
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//display stub image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();
在你getView()
ImageView image=(ImageView)vi.findViewById(R.id.imageview);
imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options.
你可以用其他選項配置,以滿足您的需求。
隨着延遲加載/通用圖像加載器,您可以查看持有人的平滑滾動和性能。 http://developer.android.com/training/improving-layouts/smooth-scrolling.html。
相關問題
- 1. 如何顯示圖像的全尺寸
- 2. 根據屏幕尺寸更改圖像
- 3. 根據圖像尺寸更改interfaceOrderation
- 4. 顯示圖像全尺寸的CSS
- 5. 固定尺寸的顯示圖像div
- 6. .NET設置的圖像顯示尺寸
- 7. Android根據設備的屏幕尺寸調整圖像尺寸
- 8. 圖像尺寸,
- 9. 視網膜顯示圖像尺寸
- 10. 顯示的圖像尺寸與所採用的尺寸相同?
- 11. 如何根據屏幕尺寸使用不同尺寸的圖像集?
- 12. PHP圖像尺寸
- 13. Carrierwave圖像尺寸
- 14. ImageView圖像尺寸
- 15. UIViewcontroller圖像尺寸
- 16. 根據圖像尺寸和像素的分辨率
- 17. 尺寸圖像的尺寸1600 * 1200
- 18. 如何顯示來自url的圖像
- 19. 如何顯示來自JavaScript的圖像
- 20. 如何顯示來自FileReferenceList的圖像?
- 21. 如何顯示來自url的圖像
- 22. 如何根據屏幕尺寸管理圖像大小
- 23. 如何根據屏幕尺寸設置背景圖像?
- 24. 如何在一定尺寸下顯示圖像而不拉伸圖像?
- 25. 如何顯示不同高度尺寸的圖像
- 26. 如何顯示比手機屏幕尺寸大的圖像?
- 27. html使圖像按鈕尺寸等於圖像尺寸
- 28. 尺寸圖像以適合WebView尺寸
- 29. Android的圖像尺寸
- 30. Android圖像的尺寸
謝謝..但根據我的要求,我不想縮小圖像。我正在做一個圖像stegnography應用程序。我從廚房獲取圖像並隱藏其中的文本。雖然獲取'3215 * 1525'內存問題的圖像維度存在...所以在我的情況下,我想隱藏從我的應用程序中獲取的庫中的大尺寸圖像。 – AbiAndroid 2013-03-28 06:50:36
您是否顯示大量圖像?在那種情況下使用UIL。如果其他人可以提出建議,我期待着一種替代解決方案。爲了更好地理解你應該看看提到的鏈接。 – Raghunandan 2013-03-28 06:52:43
http://stackoverflow.com/questions/3331527/android-resize-a-large-bitmap-file-to-scaled-output-file。我很好奇,看看另一種解決方案 – Raghunandan 2013-03-28 06:57:12