Android Question B4A control placement

Nitin Joshi

Active Member
Licensed User
Dear B4A team, I am very much comfortable with B4A programming except one thing, control placement. Even for the simplest example, view on mobile screen and view on designer is not similar. I have to put lots of efforts/trial and error to make sure view on mobile/tab screen is ok.

I am really looking for the good solution.
 

Nitin Joshi

Active Member
Licensed User
I always use AutoScaleAll line in both, Script-General & Script-Variant.
I want to understand theory/logic in detail regarding this subject, thanks.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi Nitin

When B4A was build, variant specific script was used. As B4A and Android evolved, they are no longer useful. Using anchors is best approach in new B4A.

Regards,

Anand
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Thanks Erel and Mr. Anand for your feedback. But how can we achieve below with anchors?
1) Anchors help to make the placement of controls w.r.t. left/top/right to Edge/bottom or all four sides. But when there is multiple columns and rows of Buttons then how to achieve placement correctly?
2) Anchors do not help to adjust control size in proportion.
3) With single variant, how to achieve both orientations?
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi Nitin

Please upload a small project or screen shot so that we can figure out the problem you are facing.

Regards,

Anand
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Dear Mr. Anand, I am uploading small project. Please help me to understand control placement theory...thanks.
 

Attachments

  • Test Project.zip
    17.3 KB · Views: 182
Upvote 0

emexes

Expert
Licensed User
1) ... multiple columns and rows of Buttons then how to achieve placement correctly?
2) adjust control size in proportion.
+1
I too would be interested in seeing if/how this works across even a limited range of aspect ratios, with designer and autoscaling ie without coding/scripting.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Anchors help to make the placement of controls w.r.t. left/top/right to Edge/bottom or all four sides. But when there is multiple columns and rows of Buttons then how to achieve placement correctly?
Not with anchors.

Anchors do not help to adjust control size in proportion.
That's true.

With single variant, how to achieve both orientations?
It depends on the layout. You can use two variants if you must.

Anchors is a tool that goes together with other tools. There is no goal not to use the designer script.

About the example you've uploaded. Where is the problem? What is the question?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would put all your layouts on panels.
Use AutoScale and center the panels in the DesignerScript.

Attached the mofified project.
I modified only the layouts for Home_Screen and DS1.
 

Attachments

  • Test_Project1.zip
    18.5 KB · Views: 207
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi Nitin

I think Klaus has understood your problem and given idea of the solution too, by adding panel.
Did it solve your problem ?
If not, please upload image of what you can see and what you want to see.

Regards,

Anand
 
Upvote 0
Top