Android Question [solved] Is it wrong to make an app which uses less than fullscreen?

Martincg

Member
Licensed User
Longtime User
Zipped sample to demonstrate the problem is included.
A button is on a panel which is 80%x by 80%y.
If I place a button like this
Button1.right = 80%x
and run the script in debug mode, the button1.right is at 90%x as far as a rough measurement tells me, but visually you can see it's at 90% because the right edge of the button is against the right edge of the panel.
If I increase the panel width to 100%, then the button1.right shifts to 80%x where it should be.

I can fix my problem by having a full screen panel in the background and making that the parent of everything else, but can someone explain this to me?
Should I always have a layout which uses the full screen?
 

Attachments

  • shiftingButton.zip
    9.3 KB · Views: 117
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tip: better not to use the variant specific script. Use the general one and use as few as possible variants.

90%x in the designer script means 90% of the width of the container that loaded the layout. In your case it is the activity.

You can create a panel with another layout file and then load the second layout into the new panel. In that case 90%x will be relative to the panel width.

I recommend you to use anchors instead of these percantages (except of the panel which is centered).
 
Upvote 0

Martincg

Member
Licensed User
Longtime User
When Erel says in the design tutorial
"- %x and %y values are relative to the view that loads the layout."
he doesn't mean what I thought he meant. So
button.right = 80%x
doesn't put the button right at 80% of the width of the view that holds the layout, but 80% of the that views width plus the left position of the parent of the button.
So if I want it at 80% of the screen width then I say
button.right = 80%x - parentOfButton.left.
Anything you learn can become obvious.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…