我想知道 Android 中存储位图的数组实现的最佳选择是什么。将位图存储在 ArrayList<Bitmap>
中是个好主意吗?或者这不是一个好的解决方案。
我试图存储在我的应用程序中以编程方式创建的 5 个不同位图,并将它们存储在数组中,它们将它们绘制到 Canvas 上,但它无法正常工作。
这就是我正在做的事情:
//beginning
ArrayList<Bitmap> temp = new ArrayList<Bitmap>();
//in some function where mBitmap is been created
temp.add(mBitmap);
//in my custom class which extends View
Bitmap bm = Bitmap.createBitmap(temp.get(temp.size()-1));
mCanvas.drawBitmap(bm);
invalidate();
但是来自 temp 的位图从未添加到我的 mCanvas
中.
有什么想法以及在 Android/Java 中将位图存储在数组中的最佳方式吗?
最佳答案
更好地使用LruCache用于位图缓存。请阅读Displaying Bitmaps Efficiently
关于java - Android 存储位图数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10600945/