Android Question Adjust web image to webview

jvrh_1

Active Member
Licensed User
Hello!
I need your help!
I have several images in my webpage and I want to show these images in my webview. When I write webv(I).LoadUrl("http://www.xxxxxxx.photo.jpg") I can not see all the image, only a corner.
Is there any way of adjusting the image to the webview size?
I can't download these images to my app because there are a lot of them. I need to load it online. If I could load the images in an imageview, it would be perfect!
Thanks for you help.
 

jvrh_1

Active Member
Licensed User
Really?
There is not another way?. Can I not to do un muy app?
Using a diferent container (nota webview)?
 
Upvote 0

Toky Olivier

Active Member
Licensed User
Longtime User
Download the image from your website and assign it to an ImageView not WebView for example.
See a tuto from by Erel: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/

There is ready to use Sub:
B4X:
Sub DownloadImage(Link As String, iv As ImageView)
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download(Link)
   Wait For (j) JobDone(j As HttpJob)
   If j.Success Then
     iv.Bitmap = j.GetBitmap
   End If
   j.Release
End Sub
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
There is not another way?. Can I not to do un muy app?

you have (atleast) 2 options.

either you use the real app way as Toky showed above with some aditional sizing code.

or you use a webview and put your images in an html file with the needed styling to make them fit to the given 'screen' (webview) size.

option 2 remains a oneliner while option 1 requires some more code especially when you want to display several images on screen with the correct aspect ratio etc...

it all depends what you want to do with the shown images.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…