Android Question ImageView on Panel

Sergey_New

Well-Known Member
Licensed User
Longtime User
Please help me solve the following problem:
set the maximum dimensions and center the photo on the panel for different bmp sizes.
B4X:
Dim pnHome as Panel
'The panel contains an ImageView
Dim photo As ImageView
Dim bmp As Bitmap
Dim hb, wb, hp, wp As Int
'Bmp can be portrait or landscape with any dimensions
bmp.Height=hb: bmp.Width=wb
'The panel has fixed dimensions
pnHome.Height=hp: pnHome.Width=wp
photo.Gravity=Gravity.FILL
photo.Bitmap=bmp
'photo. Left =?
'photo.Width=?
'photo. Top =?
'photo. Height=?
 

DonManfred

Expert
Licensed User
Longtime User
Dim pnHome as Panel 'The panel contains an ImageView Dim photo As ImageView Dim bmp As Bitmap Dim hb, wb, hp, wp As Int 'Bmp can be portrait or landscape with any dimensions bmp.Height=hb: bmp.Width=wb
your code does nothing. The panel does not contain any imageview at this point. You have not loaded any layout.
hb and wb are not filled with a width.

Start with posting a MORE complete code. Best is to upload a small project.

Hard to help with these - incomplete - code-snippets you posted.
 
Upvote 0
Top