In my Android app I have a custom ImageView which, based on user interaction, needs to update its image. The ImageView can only have two images, which represent the back and front of a card. So, when the user clicks a button I need to show the back of the card (set my custom's ImageView image to the back of the card and when the user cliks the button again, set the front image as ImageView drawable).
In order to accomplish this I have two methods in my custom ImageView:
public void showBack() {
setImageResource(R.drawable.card_back);
}
public void showFront() {
setImageResource(R.drawable.card_front);
}
Of course, this works great, but the memory consumption of my app sometimes get near 114 MB, and it increases as the user clicks the button (rotates the card).
Due to that, I think the problem could be produced by the change of image. The images are small, one is 104.6KB and the other 80.4KB (PNG format), so I don't understand why my app is consuming so much memory (maybe because images get allocated very times and never recycled?, or maybe because of Android's cache system of drawables?)
So, what can I do to solve my problem?
Thank you.
Image dimensions are 335 x 501