Android Question Layout changes when compiled. Why?

Jason Wood

Member
Licensed User
Hi,

I'm new to this and have just done the first 2 projects in the beginners guide.

However, I am finding an issue wherein the display layout on my phone (via the bridge) whilst using the designer is perfect. However, when I run and compile the app, the layout is now different in that it is too big and overflows the screen.

It's as if the layout when compiled gets 'zoomed in' a little pushing content off the right and bottom of the screen.

I have the resolution in the designer matched to connected device.

Why is this happening and how to prevent it?

Thanks
 

ronell

Well-Known Member
Licensed User
Longtime User
you can set the layout at runtime
B4X:
'sample
label.setlayout(50%x - label.width/2,50%x,label.width,label.height) 'this will appear in the center of the screen on any device
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
No need to set the layout in the code.

Don't try to design your layout to any specific screen size. You should instead use anchors and designer script to create a layout that looks good on all screen sizes.

I guess that you haven't set anchors and the call to AutoScaleAll in the designer script caused the layout to be enlarged.
 
Upvote 0

Jason Wood

Member
Licensed User
Ok thanks for your replies.

I'm going through the beginners guide and so far it has only instructed to use the 'designer' for the layouts and I've not seen 'designer script' being mentioned in the guide yet.
I'll look out for it then as I work through the beginners guide.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…