Android Question How to i set image & label inside Panel to resize according screen size?

ht_admin

Member
Hi again,

I want to have an image & label inside the panel, and want that image & label to resize according to screen size,
so if the panel size enlarged the image should also enlarge and fit itself inside the panel same for the label,

I tried using a script but end result was too weird and out of focus, I have attached the image to give an idea, green and black borders are the border for the image and label to resize itself.

I tried to set the anchor panel but I do not see any result

Designer script:
heightOfLabel4 = Label4.Height

ImageView1.SetLeftAndRight( Panel1.Left + 5dip, Panel1.Right - 5dip)
ImageView1.SetTopAndBottom( Panel1.Top + 1dip, Panel1.Bottom - 2dip - heightOfLabel4)

Label4.SetLeftAndRight( Panel1.Left + 5dip, Panel1.Right - 5dip)
Label4.SetTopAndBottom(ImageView1.Bottom + 5dip, Panel1.Bottom - 5dip)
 

Attachments

  • Screenshot 2021-05-27 170254.jpg
    Screenshot 2021-05-27 170254.jpg
    20.4 KB · Views: 262

ht_admin

Member
I have set the anchor property already, Left and right edge distance but don't get the result,
I have a script that resizes panel that may be an issue, not really getting error

Designer script:
'All variants script
AutoScaleAll

Panel1.SetLeftAndRight( 5dip, 50%x)
Panel2.SetLeftAndRight( Panel1.Right + 5dip, 100%x - 5dip)
Panel3.SetLeftAndRight( 5dip, 50%x)
Panel4.SetLeftAndRight( Panel3.Right + 5dip, 100%x - 5dip)

topofbox = Label3.Bottom + 10dip
MiddleOfBox  = (100%y + topofbox) / 2

Panel3.SetTopAndBottom(MiddleOfBox + 2dip, 100%y - 5dip)
Panel1.SetTopAndBottom( topofbox + 5dip,  MiddleOfBox - 2dip )

Panel4.SetTopAndBottom(MiddleOfBox + 2dip, 100%y - 5dip)
Panel2.SetTopAndBottom( topofbox + 5dip,  MiddleOfBox - 2dip )
 

Attachments

  • Screenshot 2021-05-28 141103.jpg
    Screenshot 2021-05-28 141103.jpg
    12.1 KB · Views: 213
Upvote 0

ilan

Expert
Licensed User
Longtime User
place the panels and labels without any code in the designer script and make a screenshot. i will try to help you with the script code so you have a nice layout for any screen size.

if you can please upload the project (only the bal file) and the screenshot how it should look and i will write the code for you
 
Upvote 0

ht_admin

Member
place the panels and labels without any code in the designer script and make a screenshot. i will try to help you with the script code so you have a nice layout for any screen size.

if you can please upload the project (only the bal file) and the screenshot how it should look and i will write the code for you

HI thanks for the reply and support its very kind, I want the attached image to look as it is on any screen, i got the panel script working but the inside image and label are distorted as the screen size is changed. i am making some silly mistake but not able to catch it, I also tried anchor property but it didn't work
 

Attachments

  • Screenshot 2021-06-07 122957.jpg
    Screenshot 2021-06-07 122957.jpg
    31.4 KB · Views: 218
Upvote 0
Top