Android Question Designer script commands.

MrKim

Well-Known Member
Licensed User
Longtime User
Is there a list of commands that are available in designer scripts? Or even better perhaps an example that would show how to do a really complex layout - 20 to 40 views arrayed on multiple panels?

I keep getting told I should use anchors and designer script instead of variants but I have not been successful with this. For example my layouts may change depending on screen size not resolution, which I have been doing in code because I didn't think that GetDeviceLayoutValues would be available designer scripts. Also, I have a lot of view on panels which may change depending on res./screen size. They didn't seem to place properly with anchors. It is not clear to me, is an anchor relative to the activity, or it's parent?
 

NJDude

Expert
Licensed User
Longtime User
Ok, look at the attached sample, as you will see I do not use ANY variants, just 1 script and I'm able to properly display the layout on ANY device and in ANY orientation and will work on ANY resolution (like I mentioned on another thread, you will have to create a layout for Portrait and Landscape, which is also what I've done on that simplified example).

Yes, it is that simple.

I hope this helps.
 

Attachments

  • Scripts_Sample.zip
    11.3 KB · Views: 244
Last edited:
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
Brilliant !! - Thanks !!
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I have tried it. I find it tedious, difficult, onerous. Great for simple layouts, but more complex ones - no.
If the anchors worked off the panels they are on it would be great! I could set the panels and be done But it appears they don't, they all ref the activity regardless of the panel they are on which means every single view must be placed in code.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Seems like you have a fixation with anchors, well, I have news for you, you DON'T have to use anchors all the time (or at all). The example I posted is indeed simple but the logic is the same no matter how complex the layout is, I have written apps with complex layouts and yes, they take time to create and fine tune but they work on ANY device and I do have only 1 script.

What you should do is to take a step back and look at what you currently have, to me, it looks like you have a mess, so, I recommend you reconsider your solution.

If you think that you can design a complex layout with 3 lines of code or that "anchors" are a sort of a magical tool that will do things for you automagically you are just kidding yourself.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If the anchors worked off the panels they are on it would be great!
Anchors are relative to the parent. If a view is inside a panel then its anchors will be relative to the panel.

Anchors are very useful when you want to anchor a view to one or both of the sides. For other cases you should use the designer script.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Anchors are relative to the parent. If a view is inside a panel then its anchors will be relative to the panel.

Anchors are very useful when you want to anchor a view to one or both of the sides. For other cases you should use the designer script.

I love the idea, they just never seem to do what I want (or expect) them to do. I will try to budget some time to experiment.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User

Helpful, but I am still looking for a list of Designer specific commands. For example I just discovered .SetLeftAndRight and .SetTopAndBottom which appear to be available in designer scripts, but not regular code.
...And look! Just stumbled across HorizontalCenter and VerticalCenter! I have been calcing those for years!
What else have I been missing?

And Erel - Kudos - you guys do an amazing job. My partner and I are a two man company with multiple applications comprising more than 350 Forms (activities) and 180 reports across 180 different tables. I know it is always more fun to add new features than document the old ones!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
When dealing with very complex layouts, prefer to create and arrange all views by code, delegating a sub for it
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
That's not really a good approach, you should leave the UI stuff to the designer and the logic to the code, easier to maintain and support.
An "I" is missing im my post, and it should read "I prefer", as it is just that, my preference. Designer scripts and anchors are great, but i like the way reading code trigers a visual response in my brain
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Helpful, but I am still looking for a list of Designer specific commands.
I'm afraid that you never had a look at the B4A Beginner's Guide nor at the B4X Visual Designer Booklet.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I'm afraid that you never had a look at the B4A Beginner's Guide nor at the B4X Visual Designer Booklet.

Read the beginners guide years ago. Wasn't aware of the Visual Designer Booklet. Just what I needed, has the Keywords - just what I was looking for. Thanks.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…