Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:16:06+00:00 2026-06-10T00:16:06+00:00

I am writing an Android app that uses a WebView to display content. The

  • 0

I am writing an Android app that uses a WebView to display content. The main purpose of the app is to display text for a user to read.

I am dynamically adding HTML to my WebView via JavaScript. When adding content to the bottom of the page it is not a problem. when adding content to the top, the WebView automatically scrolls to the top. That’s my problem.

I need to try and find a way to prevent my WebView from automatically scrolling to the top of the page when content is added to the top.

I do have some limitations though:

1) I am using JavaScript, but am unable to use jQuery.

2) I am currently confined to Android API 8 (v2.2).

3) I don’t want to just scroll back to my original position.
(I have found many solutions on SO for this issue in which I would just programatically scroll back to my position before the scroll. I have a current implementation of this, but it is not a smooth enough transition.)

4) I need to allow the user to continuously scroll upward while content is being added. (While I am open to an implementation of disabling scrolling to prevent the WebView from scrolling itself back up, I need to allow the user to keep scrolling up while I am adding content a screen’s height or so above them.)

Sorry if this seems confining, but you can see why I needed some advice.

Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:16:08+00:00Added an answer on June 10, 2026 at 12:16 am

    I found a way around my problem. If anyone has another, especially a more direct, answer I would still be interested.

    I was, in part, mis-diagnosing my problem. When I add HTML using: document.body.insertBefore(newDiv, topDiv.nextSibling);, I add my new HTML just below the top edge of the document.

    I thought I was scrolling back up to the top of the screen (co-ordinates [0,0]), but instead the document length was changing and my current Y position stayed the same. So the co-ordinates I was viewing were constant, but the HTML those co-ordinates displayed changed. The effect was “scrolling up” the page.

    I ended up adding a HUGE div of white space above my visible text. Every time I add HTML it shrinks by the exact height of the added HTML. This offsets the added text, allowing my visible screen to stay the exact same. This means NO scrolling, which is a much more fluid UI.

    This gives a whole different set things to work around, like stopping the user from scrolling the whole length of my white space and ensuring I don’t make my WebView larger than my max size. The trade-offs are well worth it though, as the user experience is drastically improved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app in Android that uses a WebView to display HTML
I am currently writing an Android app that, among other things, uses text information
I am writing and Android app that uses the camera. Once activity saves and
I'm writing a small android app that lets the user pick a date and
I'm writing an Android app which uses Javascript in a WebView for most of
I am (re)writing an android app that uses an SQLite database to store various
I have an android app I am writing that uses SQLite. I want the
I'm writing an app for Android that uses fragment shaders for image processing. I'm
Im writing an android app that connects to my own Jersey rest client. HTTP
I'm writing an Android app that needs to access GMail, and I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.