2

I have a view hierarchy like this, a vertical ScrollView with a vertical LinearLayout containing two children:

ScrollView ->orientation:vertical, width:fill_parent, height: fill_parent LinearLayout -> orientation:vertical, width:fill_parent, height: fill_parent WebView -> width:fill_parent, height: fill_parent GoogleAdView -> width:wrap_content, height:wrap_content 

When scrolling to the bottom of the webview and clicking on any link there, though the page loads , the scrollbar stays at the bottom rather than moving to the top. I can programatically set the scroll using scroll.fullScroll(ScrollView.FOCUS_UP), but that causes the scrollbar to jump up visibly. I have tried hiding the scrollbar before the page loads with scrollView.setVerticalScrollBarEnabled(false) and then re-enabling it after the page loads before calling scroll.fullScroll(ScrollView.FOCUS_UP) but that still causes the scrollbar to "jump".

The WebView by itself handles scrolling much more nicely on page changes, looks like it hides the scrollbar and then makes it appear on top of the page after load. Is there a way to maintain this with ScrollView?

3 Answers 3

2

You cannot reliably put a WebView in a ScrollView.

Either embed your ad in your Web content, leave the banner fixed on the screen, or work out some other trigger to animate hiding the ad (e.g., goes away after 5 seconds).

Sign up to request clarification or add additional context in comments.

Comments

0

I've solved this by adding the AD inside the webview. Unfortunately you won't be able to use any Ad network SDK's, but it's a much better user experience.

Use javascript injection to insert your ads after the webview loads.

Comments

0

The trick is to use loadDataWithBaseURL when loading content into the WebView. Simply doing a loadData doesn't cause the scroll offset to reset.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.