Android Question Calculate imageview height.

Sub7

Active Member
Licensed 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:
imgview.top = 0%y
imgview.SetLeftAndRight(5%x,95%x)
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?

B4X:
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

Thanks

ps i tried something like this but is not ok

B4X:
   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
 

Sub7

Active Member
Licensed 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.
 

Sub7

Active Member
Licensed User
So was only that: imageview.Color = Colors.Transparent :eek:
Grazie luca, nice xmass example.
 
Top