"Align" attribute

pleskina

Member
Licensed User
Longtime User
Hello,

Let me make my 5 cents with a wish...

Creating different layouts for hundreds of devices is pain in... you know where. Google really did it to us with Android. On the other hand, creating dynamic layout using designer scripts is even bigger pain in the same place.

Many advanced "controls" in IDEs have automatic "align" attribute which is set in events like "repaint" (in our case that one happens in Activity.Resume) which helps control to align to specific position inside parent. This keeps things in position without hundreds of lines of code.

Another a little bit more advanced attribute is "anchor" - that one would keep boundaries of a control always in the same place. Delphi VCL has excellent implementation of this: if control is EditText, for example, and has attribute Anchor.Right and Anchor.Left, then its left and right position would not change with screen size, but width would.

I do not know how hard are these things to do (bring from Java level to B4A), but would rapidly simplify dynamic screen building...

Regards,
Davor
 

pleskina

Member
Licensed User
Longtime User
Actually yes, but that is much slower and prone to errors. I was talking more about "visual" design anchoring where every layout adopt to any screen size dynamically. I don't know if you ever tried any visual designers such as Delphi's to understand what I am talking about. Nevertheless, that is just an idea/suggestion, B4A is powerful tool far better than various XML based layout "designers".

TY
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Anchor / docking / feel are useful methods to build the UI. I'm familiar with these methods.

From my experience they are not powerful enough to handle more complicated interfaces. In such cases you quickly realize that it will be easier to implement the solution by code.

Most phones interfaces are complicated due to the limited screen size. The designer script with the UI cloud (have you tried it?) and abstract designer should allow you to build such interfaces.
 

pleskina

Member
Licensed User
Longtime User
Hello Erel,

Yes sure I have tried script and all variants and cloud you so perfectly designed for B4A. But it looks like you have never tried Delphi VCL and visual components which perfectly align and fit into place at the moment you change "form" (in our case activity/screen) resolution. Maybe if I show you an example on few images.
Horizontal.PNG

Vertical.PNG


As you can see, controls are "anchored" and when you resize the form, they are always adjusted and in the same place:
- upper panel is anchored to top and bottom, left and right and always stays at the same distance from form borders. All controls on it are anchored the same except Memo1, which is also anchored to bottom and will always properly fill the space on panel
- Lower panel is anchored to bottom, left and right so it will preserve the same height and position, while becoming wider or narrowser as needed
- ListBox on the left is anchored to top and bottom so will be always the same
- the same with RadioGroup1
- GroupBox1 will adjust its width, and because Edit2 is anchored to its left and right, will adopt the size to his parent width (GroupBox1)
- The image you see is "aligned" to bottom of GroupBox1 and will always align to it's bottom, adopting width and height

"Align" behaves similarly to adjust to form (no additional code):
Horizontal2.PNG

Vertical2.PNG


There is no need to write scripts for that as it is implamented in OnPaint event (I am sure Android has some equivalent of that in Java libraries).

I will say again that I do not know enough about Java Layer of Android API, but if there is such event as "create" - probably some kind of automatic "ResizeControls" event can happen, which would adjust controls embedded on parent view taking in account properties as align, anchor and some other. Very same way as for example browsers do with containers such as DIV (60% is always 60% if HTML document area size changes, as well as center is always center).

In one project made a Sub called "AdjustMaskControls" which iterates views on activity and adjusts views on Activity_Resume. But things like additional attributes then must be stored somewhere in additional data structures and solution is not elegant and easy when there are more complex "forms" on which views contain other views which contain other views... I am sure you perfectly understand what I am talking about.

Sorry for bothering you and the community, but I think ideas must be said out even if never get implemented! :) I don't think we (you) should make another Delphi of B4A, but maybe we can make thing even better. If you help me with API, maybe I can contribute to development of such dynamically alignable controls in form of a library.

Regards,
D.
 

anna7

Member
Licensed User
Longtime User
I am agree with pleskina

Anchor / docking / feel are useful methods to build the UI. I'm familiar with these methods.

From my experience they are not powerful enough to handle more complicated interfaces. In such cases you quickly realize that it will be easier to implement the solution by code.

Most phones interfaces are complicated due to the limited screen size. The designer script with the UI cloud (have you tried it?) and abstract designer should allow you to build such interfaces.

And would not be possible to use both possibilities? scripts and "anchor", "dock", etc. properties. I don't know. It's only a suggestion / question. :)
 
Last edited:

qsrtech

Active Member
Licensed User
Longtime User
Delphi - powerful

+1, Nice to see a fellow Delphi user around here. I'm currently porting my POS app from Delphi(7) to b4a. 10's of thousands of lines. Mostly going ok. As I've stated in other posts, a couple key things missing are Built-in result variables and property getters/setters (which is not unique to Delphi). I understand things take time, so I can imagine b4a being a true RAD IDE in another year or two. After all it took VB and Delphi many years to become what they are today, and I'm sure it took 10's to hundreds of people to get them there.

Keep up the good work Erel.
 
Top