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=?
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Nice item!
Unfortunately, I didn’t find how to change its size and position during execution.
 
Upvote 0

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

Sergey_New

Well-Known Member
Licensed User
Longtime User
Hard to help with these - incomplete - code-snippets you posted.
I outlined only the algorithm of actions and thought that the rest was clear. I'll create an example and attach it.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Attached an example.
 

Attachments

  • temp.zip
    20.3 KB · Views: 138
Upvote 0
Top