Showing posts with label Drawable. Show all posts
Showing posts with label Drawable. Show all posts
Wednesday, March 27, 2013
Android: How to compare Drawables
Answer:
drawable1.getConstantState().equals(drawable2.getConstantState());
It doesn't compare actual data (bytes of images) so it is fast and memory efficient.
Wednesday, May 9, 2012
Android: (Memory Management) memory leak - free ImageView resource
In order to free ImageView/Drawable object to gain memory space:
Usually you do it on onDestroy()
For Bitmap, you use recycle().
ImageView v = (ImageView) _________;
((BitmapDrawable) v.getDrawable()).setCallback(null);
Usually you do it on onDestroy()
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
For Bitmap, you use recycle().
Subscribe to:
Posts (Atom)