Private Sub ResizeImageViewBasedOnBitmapRatio(iv As B4XView, bmp As B4XBitmap)
Dim bmpRatio As Float = bmp.Width / bmp.Height
Dim viewRatio As Float = iv.Parent.Width / iv.Parent.Height
Dim Height, Width As Int
If viewRatio > bmpRatio Then
Height = iv.Parent.Height
Width = iv.Parent.Height * bmpRatio
Else
Width = iv.Parent.Width
Height = iv.Parent.Width / bmpRatio
End If
iv.SetLayoutAnimated(0, iv.Parent.Width / 2 - Width / 2, iv.Parent.Height / 2 - Height / 2, Width, Height)
iv.SetBitmap(bmp) ' <<ERROR in this line, Type does not match (B4IPanelView)
#if B4A
Dim iiv As ImageView = iv
iiv.Gravity = Gravity.FILL
#End If
End Sub