scrollview - Android: HorizontalScrollView Scrolling Issue -


i have customhorizontalscrollview, linearlayout child, , initial 9 custom views under linearlayout.

when scroll right, need add 3 more child views linearlayout, , remove first 3 children, such 9 child views present @ time.

we added detection points based on view ids, in such way if currentviewid > lastchildid - 0.33f * viewsizelimit viewsizelimit = 9. if valid, that's time add/remove views linearlayout.

first issue encountered when remove views linearlayout, children shifted left. if currentviewid = 7, , current view on detection zone add 3 views end, , remove 3 views front. currentviewid = 4 due shift.

we added scrollby method of horizontalscrollview compensate view shift , works if scrolling not fast.

here's example logs:

07-01 17:01:34.304: info/gta(2476): currentviewid: 6 07-01 17:01:34.304: info/gta(2476): scroll distance: 8 07-01 17:01:34.373: info/gta(2476): currentviewid: 6 07-01 17:01:34.383: info/gta(2476): scroll distance: 41 07-01 17:01:34.463: info/gta(2476): currentviewid: 7 07-01 17:01:34.463: info/gta(2476): scroll distance: 25 07-01 17:01:34.633: info/gta(2476): added new views end 07-01 17:01:34.643: info/gta(2476): currentviewid: 4 07-01 17:01:34.653: info/gta(2476): scroll distance: -1440 07-01 17:01:34.653: info/gta(2476): head view id: 4 | tail view id: 12 07-01 17:01:34.673: info/gta(2476): currentviewid: 7 07-01 17:01:34.673: info/gta(2476): scroll distance: 22 07-01 17:01:34.733: info/gta(2476): currentviewid: 7 

here's log when scrolling/flinging scrollview fast:

07-01 17:03:48.633: info/gta(2476): currentviewid: 6 07-01 17:03:48.643: info/gta(2476): scroll distance: 158 07-01 17:03:48.693: info/gta(2476): currentviewid: 6 07-01 17:03:48.704: info/gta(2476): scroll distance: 124 07-01 17:03:48.753: info/gta(2476): currentviewid: 7 07-01 17:03:48.753: info/gta(2476): scroll distance: 114 07-01 17:03:48.914: info/gta(2476): added new views end 07-01 17:03:48.914: info/gta(2476): currentviewid: 4 07-01 17:03:48.914: info/gta(2476): scroll distance: -1440 07-01 17:03:48.914: info/gta(2476): head view id: 4 | tail view id: 12 07-01 17:03:48.974: info/gta(2476): currentviewid: 10 07-01 17:03:48.974: info/gta(2476): scroll distance: 1843 07-01 17:03:49.194: info/gta(2476): added new views end 07-01 17:03:49.204: info/gta(2476): currentviewid: 7 07-01 17:03:49.204: info/gta(2476): scroll distance: -1440 07-01 17:03:49.204: info/gta(2476): head view id: 7 | tail view id: 15 07-01 17:03:49.253: info/gta(2476): currentviewid: 14 07-01 17:03:49.264: info/gta(2476): scroll distance: 1866 07-01 17:03:49.403: info/gta(2476): added new views end 07-01 17:03:49.414: info/gta(2476): currentviewid: 11 07-01 17:03:49.414: info/gta(2476): scroll distance: -1440 07-01 17:03:49.414: info/gta(2476): head view id: 10 | tail view id: 18 07-01 17:03:49.463: info/gta(2476): currentviewid: 18 07-01 17:03:49.463: info/gta(2476): scroll distance: 1551 07-01 17:03:49.703: info/gta(2476): added new views end 07-01 17:03:49.713: info/gta(2476): currentviewid: 15 07-01 17:03:49.713: info/gta(2476): scroll distance: -1440 07-01 17:03:49.713: info/gta(2476): head view id: 13 | tail view id: 21 

from logs, can seen horizontalscrollview scrolls huge amounts (ie. 1843, 1866, 1551). -1440 value we're seeing scrollby compensation added set proper view visible in viewport.

so problem can't seem find out why horizontalscrollview scrolls such large distances. reason occurrence?

is there better way of implementing aside using horizontalscrollview?

should consider using game engine this?

thanks.

i'd suggest using gallery, horizontal listview.

the idea spinneradapter implementation provides gallery view width of 1/9th of area otherwise standard implementation. give unlimited scrolling think (assuming i've understood requirements) give effect you're looking for. have happy side-effect of snapping position.

i hope that's helpful.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -