HorizontalScrollView snap to page?

by Jeffrey Sambells » Fri, 25 Sep 2009 22:09:45 GMT


Sponsored Links
 Is there a way to make a HorizontalScrollView "snap" to a page? Let's say I
have a hsv with an overall width of 800 but only 200 viewable. I'd like to
have the scroll position snap every 200 pixels so that the resting position
is always 200 offset from the origin (thus always displaying a full "page").
Is there an easy way to do this or do I have to somehow override the gesture
interactions?

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Bitmaps and OutOfMemoryError: Best Practices needed

I'm running into OutOfMemoryErrors when allocating bitmaps. This is
not something I can reproduce with emulators, and has been reported by
a few beta testers with the HTC Incredible.

I'm not sure I can solve this directly, and my best hope is to follow
best practices for bitmaps and memory thereof. But looking for those
best practices based on groups archives left me with more questions
than answers. If anyone has a chapter about this in their book, I will
buy the book.

Here are the things I've mulled over so far:

1. I have a bitmap for a drawing buffer. It is about 3-4 megabytes on
some devices. This is the biggest bitmap I have, and without it, I
wouldn't be able to much of anything useful in my app.  I am assuming
that it would not be useful to use inPurgeable if this is a bitmap
that is drawn into. Is this true?

2. Next biggest in the hierarchy are some bitmaps that are about 22K
bytes and 256K unpacked.  Since I believe about 25 of these might be
used at one time, I have a cache with a size of 25.
I am careful to use BitmapFactory.Options.InPurgeable, so I believe
that could make them take only 22K each, but I don't see that as
guaranteed. Maybe they are taking 256K each, which would put me in the
danger zone.
As they are cycled out of the cache, I call bitmap.recycle(). I think
this a good practice. Is it?

3. Next are some resources with icon size 32x32 pixels.  There are
about 50 that could be used or reused. If I use code like this:

                                                Drawable s =
mCtx.getResources().getDrawable(R.drawable.symbol_icon);
Where s is a local variable to rendering. Suppose I call this 37
times.
Am I to assume that Android will do something smart like create only
one bitmap for this resource even if it is used 37 times?
Or am I to assume that Android will do something stupid like create 37
bitmaps and keep references in an obscure location that will prevent
garbage collection?
Do I need to get more access to these bitmaps and do something smart
myself?

4. Finally are some other icons used for menus and ImageButtons. Most
are declared in layout files - so I don't touch the bitmaps directly.

Can someone better informed than me comment on these assumptions? I'd
like to make my memory usage more efficient, but don't want to spend
time on things that will amount to shuffling chairs on the Titanic.

And how do I best measure this usage? Interestingly enough, I've tried
using the Allocation Tracker and it says I haven't allocated a single
bitmap. In light of the above, I don't think that's right.

Thanks in advance.

Nathan

-- 

2. Replacing Contact Application with new Contact application

Hi

I am new to android and trying to make a new application on the
emulator.

I have used the current contact application code and made some changes
in the code and installed it as myContacts.apk.

Now a new icon has come in the menu for myContacts to launch my
application.

What changes is to be done in myContacts application or Launcher so
that on clicking Contacts icon on home screen it ask to launch which
application Contacts or MyContacts.

Please help me in this regard.

Thanks

-- 

3. Finish an activity not started from the service

4. GPS fix status detection

5. O2 APN settings

6. Transparency with 2 .jpg files

7. NetDragon... Where do your apps go?