Android Question Webview update hides other views

nwhitfield

Active Member
Licensed User
Longtime User
This is a weird one, which is making me tear my hair out. I have a page which displays a user's profile. The top half is labels and an imageview, belows a toolbar, with two items to move backwards and forwards through the list (swiping is used for something else, and this inner part of the display is a page within a tabstripcontoller).

The main part of the profile is html (so that users can use markdown to create them), displayed in a webview. And below that is a nav bar.

When the user taps to move from one profile to another, all the views are reused, with the content for the next profile loaded in. And most of the time this works perfectly. EXCEPT... on my Android 8 device (but not the slower Android 6 one) some profiles, typically the shorter ones, cause lots of the other views to vanish when the HTML is loaded. Everything loads, as it ought to, and then it just vanishes.

I've checked and if I simply never change the HTML, everything else is fine. I've tried loading the HTML directly, or saving it to a file and using loadurl instead.

The first screen shows what a profile's supposed to look like. The second shows what happens sometimes - only sometimes - after updating the content in the webview. Moving to another profile renders everything correctly again.

I can also partly solve the problem by calling .bringToFront on most of the views (but the navbar won't play ball). And note too that the border on the shift buttons has also, somehow, been removed, despite there being no code that addresses that anywhere in the app.

There no code that uses sendToBack on those views; there's nothing happening after the webview is updated, beyond turning the progress indicator off. So what about a webview could make this happen?

Screenshot_20210303-141249.png
Screenshot_20210303-141256.png
 

omarruben

Active Member
Licensed User
Longtime User
I would prefer NOT to use webview, what I would do is, download the profiles and show on custom list, and give horizontal scrolling.
Check this post :
 
Upvote 0

nwhitfield

Active Member
Licensed User
Longtime User
It's very peculiar; there aren't any references elsewhere to things like the border properties that get changed; and it happens on one test phone, but not on another. So while I conceded a bug is entirely possible, I am starting to suspect something in the firmware on this particular device.

I had another brainwave last night; the profiles affected are uniformly those with shorter text, which obviously has an effect on the scroll position and scroll bar of the webview. So, this morning I made a tweak to the code that builds the profile HTML. Before the closing BODY tag, I added this

HTML:
<div style='height:20rem;background-color:gray'></div>

The colour is simply so I can see it working. And it does. This ensure that even the shortest profiles will be able to scroll up and down a little bit, and suddenly, the page layout works again, all the time. No flicker, no disappearing labels or images.
 
Upvote 0
Top