Android Question Adjusting an image displayed with webview to the screen size

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I am using webview to display images stored in an internal directory (with an old activity application (not B4XPages)).
The problem is that there are images of many sizes and I would like them all to fit the screen size of the device.
Is this possible?
Thank you.
 
Solution
Attached, one of the solutions.
Fit the image to the width and height of the webview.

press the button to load the image
1667238548560.png
1667240719132.png


Is that what you want to do with the image?

TILogistic

Expert
Licensed User
Longtime User
yes, webview use Css
example:
or

JavaScript

 
Last edited:
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, this is the code I use to display the photo.
Thank you.

B4X:
Sub VerFoto   
    Dim cFoto, cDir, cExt, cImagePath As String
    Dim mXui As XUI
    '   
    cDir = globales.cDirFotosOriginales
    cExt = globales.DBconex.ExecQuerySingleResult("select ftpTipoFotos from tbEmpresa limit 1")
    cFoto = globales.cCodigoEmpresa & cCodigoArticulo &"."& cExt
    '
    If File.Exists( cDir, cFoto ) Then
        Try
            cImagePath = mXui.FileUri(cDir,cFoto)           
        Catch
            Log(LastException.Message)
        End Try
    Else
        cImagePath = mXui.FileUri(globales.cDirFotos,globales.cNoTieneFoto)
    End If
    '
    wv1.LoadHtml($"<HTML><HEAD></HEAD><BODY><IMG SRC="${cImagePath}"></BODY></HTML>"$)
    '
    pnFoto.Visible = True
    pnFoto.BringToFront
    btCierra.BringToFront
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Attached, one of the solutions.
Fit the image to the width and height of the webview.

press the button to load the image
1667238548560.png
1667240719132.png


Is that what you want to do with the image?
 

Attachments

  • webview-image.zip
    31.9 KB · Views: 171
Last edited:
Upvote 1
Solution
Top