Android Question Calculate imageview height.


Active Member
Licensed User
Longtime User
Well it seems stupid but i miss something.
Let say i have an imageview and i want to put a logo inside
i set this imageview in the script editor in this way:
B4X: = 0%y

I know that i want the logo to cover almost all screen 5/95 but i dont know how to set the height correctly, for example in photoshop you can resize by keeping proportions, but here?

Dim imgwidth as int
imgwidth = imgview.width

Image gravity FILL

how i can calculate the height so the image does not get streched knowing only the width? :p


ps i tried something like this but is not ok

   Dim logobmp As Bitmap
   logobmp.Initialize(File.DirAssets, "logo.png")
   Dim logoHeight As Int
   logoHeight = logobmp.Height /logobmp.Width *logobmp .Width
   imageview.Height = logoHeight
   img_imageview.Bitmap = logobmp


Active Member
Licensed User
Longtime User
Ciao Luca,
while this works and i've tried that before, this logo is a png file with transparency.
the output of that function is correct image but with a white background which is not ok.
Upvote 0