Android Question Why does my webview cause my scrollview to jump to the bottom?

PhilN

Member
Licensed User
Longtime User
When I load a long (tall) webview in a scrollview, and click somewhere on the webview, the scrollview jumps to the bottom of the webview! Why is this? This is an "about" scrollview and simply has a bitmap at the top and a webview below that. I have tried many things to fix this but can't seem to nail it. I don't understand it. What can one do to fix this?

Can anyone please help me. Thanks in advance!
 

PhilN

Member
Licensed User
Longtime User
Hi NJ. Here is the main code...

B4X:
Sub Globals
    Dim scvAbout As ScrollView
    Dim pnlAbout As Panel
    Dim WebView6 As WebView
    Dim Label1 As Label
    Dim btnAboutOK As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
       
    End If
   
    Activity.LoadLayout("AboutScrollView.bal")
    scvAbout.Panel.LoadLayout("About")
    scvAbout.Panel.Height = pnlAbout.Height
   
    Dim DarkGrey As Int = Colors.RGB(43,43,43)
    Dim LightGrey As Int = Colors.RGB(204,204,204)
    pnlAbout.Color = DarkGrey
   
    WebView6.LoadUrl("file:///android_asset/about.html")
    WebView6.Color = Colors.ARGB(255,43,43,43)
   
    scvAbout.ScrollPosition = 0 'set position to the top
End Sub

I can't see anything wrong with it. I have also included the scrollview test zip if you have a chance to see what may be wrong. I'm using a Samsung Galaxy S2 480x800 screen size. Thanks for trying to help!
 

Attachments

  • SCVTest.zip
    70.7 KB · Views: 181
Upvote 0

PhilN

Member
Licensed User
Longtime User
Hi NJ. The about was in the files folder when I zipped it. I thought it would be included automatically. Attached is the about.html. Thanks again. :)
 

Attachments

  • about.zip
    984 bytes · Views: 175
Upvote 0

NJDude

Expert
Licensed User
Longtime User
For future reference, you don't have to zip the file manually, you have to use the IDE to export it, click on FILE -> Export As ZIP, that will include everything.

I'll take a look at your code later in the day.
 
Upvote 0

PhilN

Member
Licensed User
Longtime User
Thanks NJ. I did use the IDE to export it, but as it was not included in the files section of the IDE, it was not included in the zip file that the IDE generated (well that's how I reason). I also thought it would include everything, but it didn't. Maybe because I have an older ver of B4A. Anyway, thanks for taking the time to look at it.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
I see you have an older version of B4A, so, you will get an error when you open the attached project, which is your own code with some modifications.

You should also use the designer scripts to create your layouts to make them scale correctly on different devices, otherwise you will see problems like this on TABLETS or LARGE SCREEN PHONES.
 

Attachments

  • SCV_New.zip
    71.1 KB · Views: 172
Upvote 0

PhilN

Member
Licensed User
Longtime User
Hi NJ. Thanks for all your trouble so far. I will follow your advice on the designer scripts but later. Anyway... I have imported the project manually (old ver of B4A) as it would not load the .bal files in the designer. I see that you are re-running a designer script which seems to be a key in solving this problem of mine. I cannot read the About.bal file which contains the (designer script) that you created as your B4A is newer. Can you please post just the code lines that you used in the designer script so that I can add them into the proj manually. Thanks.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Ok, on your layouts, I got rid of the variants you had and used a 320 x 480, and I added this code to the ABOUT layout designer scripts.
B4X:
pnlAbout.Height = 100%y
btnAboutOK.Bottom = 100%y - 10dip
WebView6.SetTopAndBottom(imgHikers.Bottom + 10dip, btnAboutOK.Top - 10dip)
 
Upvote 0
Top