Here's the layout (XML) structure.
<RelativeLayout>
<Linearlayout> <ScrollView> ...<Linearlayout>...</Linearlayout> </ScrollView> </Linearlayout> ...(Buttons)... </RelativeLayout>I am trying to make the ScrollView scroll slow ( like some kind of slider ) so that it scrolls for example one px than waits for 10 milliseconds and scrolls another px ... until it has scrolled by 100px. If i call scrollBy(100,0) (e.g.) it just switches to the specified positi开发者_StackOverflowon, but theres no visible movement in between.
public void move(int x, int y)
{
Activity context = (Activity)getContext();
context.runOnUiThread(new Runnable()
{
@Override
public void run()
{
for(int i=0;i<100;i++)
{
scrollBy(-1,0); try{ Thread.sleep(20); } catch(Exception e){}
}
}
});
}
I've been trying Threads (like this) in the ScrollView ( i extended it) and the Activity. If there's any way to make it move slowly i'd be glad to know. Thanks!
You could use the Timer and TimerTask class and update scrollTo method by 1 until you reach 100.
https://github.com/blessenm/SlideshowDemo
The above is a continuous slider example which shows the use of the above methods.
Have you tried using smoothScrollBy
?
精彩评论