I am reading about setDrawingCacheEnabled
and getDrawingCache
and I was wondering when is it good to use it or when its not good.
Basically in my case I have an HorizontalScrollView
with many things inside it so its scrolls left/right and most of the things are not visible.
If I use setDrawingCacheEnabled(true)
on the views, does it help? or this is only when I use custom views and I call getDrawingCache()
?
Is there any other 'cache' way to use in a HorizontalScrollView
?
TouchInterceptor.java - This is class responsible for reordering your playlist in the default music player. It uses setDrawingCacheEnabled
when you start dragging the current view. Basically, it creates a bitmap from the ListView
item and drag it. Take a closer look at onInterceptTouchEvent
method.
It's definitely useful for screenshots as Marcel said. It is also very useful performance-wise, as that is what it was created for. It does use up more memory, as you render the view into a bitmap first.
What you do is, you setDrawingCacheEnabled
to true
, call getDrawingCache
which returns a bitmap and store this bitmap. In onDraw
, you do draw the bitmap you got if the cache is on, or the view otherwise. This can be very nice when scrolling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With