ivesingh
ivesingh

Reputation: 888

Auto-Scroll WebView

I have a WebView which displays an HTML file and I would like to add an option to be able to scroll down automatically when a button is clicked with a given speed. How should I approach on doing this?

Upvotes: 0

Views: 1755

Answers (2)

Jack Miller
Jack Miller

Reputation: 7647

You just need an HTML button which performs a JavaScript call.

Something like:

$('a[href=#bottom]').click(function(){
    $('html, body').animate({scrollTop:0}, 'slow');
});

Inspired by: Slow down scroll to top event by jQuery animate

Upvotes: 0

glo
glo

Reputation: 1428

You can calculate the speed of button clicks by taking difference in unix timestamp between clicks and then you can impliment something like

private Runnable mScrollDown = new Runnable()
{
    public void run()
    {
        WebView webview = (WebView)findViewById(R.id.web_url);
        webview.scrollBy(0, scrollSpeed);
        mHandler.postDelayed(this, 200);
    }
};

I got the answer from link given below. Check it for details.

Auto-scrolling a WebView with handlers

Upvotes: 1

Related Questions