Friday, August 26, 2011

[android-developers] Re: Lazy loading in HorizontalScrollView to prevent Out of Memory issue

@Drezden

Your correct i am using larger number of images added as child view of
LinearLayout which is a child view of HorizontalScrollView,
Like OOM issue is happening at different number of images decoded from
BitmapFactory on different devices like Google Nexus it is after 160
images , Xoom 253 images and so on.

For decoding i am already using options and calculating inSampleSize
only not inTempStorage(will it add any improvement if i use it?).

Also i have cache that has soft reference to improve efficiency in
terms of number of images decoded because i am recycling bitmap, but
eventually it will crash due to OOM.


thanks

On Aug 26, 8:42 am, Drezden <mmjohns...@gmail.com> wrote:
> Are you loading a large number of images into your
> HorizontalScrollView?
>
> If so, then you are probably running out of memory from the Bitmap
> creation process.  You need to subsample them so you aren't loading
> billboard sized images into your app, like this.
>
> BitmapFactory.Options options = new BitmapFactory.Options();
> options.inSampleSize = 2;
> options.inTempStorage = new byte[16*1024];
>
> Bitmap img =
> BitmapFactory.decodeStream(getContentResolver().openInputStream(imagePath), null,options);
>
> On Aug 26, 1:00 am, himanshu jain <himanshu....@gmail.com> wrote:
>
>
>
>
>
>
>
> > I want to add lazy loading feature to HorizontalScrollView, It has
> > linearlayout as a child and i am addding to linearlayout,
>
> > I am interested in listening to the event when the child view is out
> > of the visibility area,  I see in linearlayout implementation it does
> > not call either dispatchViewVisibility or onDraw on child view , why i
> > want that because bitmap attached to the child view can be recycled
> > and create bitmap again when child view is visible (well that is a
> > separate part ,How can i create that bitmap very fast, I am planning
> > to use opengl for that) but the question is how can make such custom
> > view.
>
> > I can not use gallery view because it does not solve my purpose
>
> > I saw that viewgroup has feature of dispatchingViewVisibility and
> > dispatchOnDraw but not sure how to use that with
> > HorizontalScrollView.?
>
> > All i am doing to prevent Out of Memory issue
>
> > Any suggestion and help would be appreciated
>
> > thanks

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate