Scroll a Gallery widget?
I'm using a Gallery
widget. I'd like to automate scrolling. Not sure if this is possible?
Gallery has a scrollTo()
and scrollBy()
set of methods, which I can call from a timer etc, but that ends up scrolling the entire gallery widget itself, not its开发者_Python百科 children view content.
There must be some way to automate scrolling?
Thanks
I'm using the Gallery's "onFling" wrapped in a Timer:
bannerView.onFling(null, null, flingSpeed, 0);
where flingSpeed is the speed you need for the gallery to move to the next item. I'm my case I got an empirical value of -650F (for a 260x80 image plus padding). However, because of the different screen sizes and densities, I multiply my empirical value by the screen density to get it right:
float flingSpeed = -650F * getBaseContext().getResources().getDisplayMetrics().density
The empirical value is probably going to be different for you so you should adapt it to your situation.
AFAIK it isn't possible to have a scrollable widget with the standard android SDK. But some home replacement apps provide a way to do it, like LauncherPro, ADWLauncher or Home++.
More info here and here
精彩评论