Android Question B4A control placement

Nitin Joshi

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

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.
 

AnandGupta

Well-Known Member
Licensed 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
 

Nitin Joshi

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?
 

AnandGupta

Well-Known Member
Licensed User
Hi Nitin

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

Regards,

Anand
 

emexes

Well-Known Member
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.
 

Erel

Administrator
Staff member
Licensed 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?
 

klaus

Expert
Licensed 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

AnandGupta

Well-Known Member
Licensed 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
 
Top