Android Question UI Implementation: Code vs Layout?

Hi, Which approach is better for implementing a user interface: direct coding or using Designer (layout)? Which method offers greater speed and is more standard? Furthermore, if the UI is implemented with a layout, is it possible for it and the .bal files to be decompiled and stolen? If so, how can this be prevented?
 
I checked, and the .bal files are extracted from the Assets folder after decompilation, which can be opened in the designer of another B4A project. How can we prevent the theft of the application's user interface?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I checked, and the .bal files are extracted from the Assets folder after decompilation, which can be opened in the designer of another B4A project. How can we prevent the theft of the application's user interface?
If the layout files are stolen, either the person is also a B4X member or he needs to learn B4X.
In assets folder, there maybe other files like strings.db, json and PNG files.
Nothing much can be done.
For me the code is more valuable.
 
Upvote 0
If the layout files are stolen, either the person is also a B4X member or he needs to learn B4X.
In assets folder, there maybe other files like strings.db, json and PNG files.
Nothing much can be done.
For me the code is more valuable.
Thank you very much for your answer, but UI design with Designer is much faster and more efficient.
I am also very interested to know @Erel answer.
 
Upvote 0

epiCode

Active Member
Licensed User
Hi, Which approach is better for implementing a user interface: direct coding or using Designer (layout)? Which method offers greater speed and is more standard? Furthermore, if the UI is implemented with a layout, is it possible for it and the .bal files to be decompiled and stolen? If so, how can this be prevented?
Generation of interface by coding is way faster then loading a layout.
Use it only if your interface has too many elements.

As for theft, all apk can be decompiled. A general thumb rule is that if it runs, it can be hacked.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I never like the idea of using code to generate the layout.
For me, designing the layout have more benefits.
  1. Straight away you can preview using B4A designer app.
  2. Future editing, you don't need to remember and interpret the code like a machine.
  3. Easier distribution and sharing of project. Another developer can easily recognize the design.
  4. Using anchor and calculation of position are much easier
  5. Usage of designer script and DSE
  6. Convenient of copy and paste on another platforms
  7. I believe on separation of concern, RAD and fast prototyping
  8. Make code less complex and shorter
  9. Drag and drop, resizing, layer, positioning, show and hide, choose colors, fonts or other properties
  10. Make more sense to me

There are no right or wrong. More to personal preferences.
 
Upvote 0

epiCode

Active Member
Licensed User
I never like the idea of using code to generate the layout.
For me, designing the layout have more benefits.
  1. Straight away you can preview using B4A designer app.
  2. Future editing, you don't need to remember and interpret the code like a machine.
  3. Easier distribution and sharing of project. Another developer can easily recognize the design.
  4. Using anchor and calculation of position are much easier
  5. Usage of designer script and DSE
  6. Convenient of copy and paste on another platforms
  7. I believe on separation of concern, RAD and fast prototyping
  8. Make code less complex and shorter
  9. Drag and drop, resizing, layer, positioning, show and hide, choose colors, fonts or other properties
  10. Make more sense to me

There are no right or wrong. More to personal preferences.
You are right.
However in instances where you are creating a complex layout in lots of cards in lets say a large xCLV list using code is better than layout IMO.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
You are right.
However in instances where you are creating a complex layout in lots of cards in lets say a large xCLV list using code is better than layout IMO.
I don't agree.
For me, using layout solve the problem of creating a complex CustomListview items.

In a current project I am working on, I have solved the previous developer problem by replacing the original code by layout design.
 
Upvote 0
I highly recommend using the designer. In addition to the excellent points @aeric wrote, layout files are mostly cross platform and they handle screen size changes, something that is more difficult to do programmatically.
Thank you sincerely for your response 🙏 Definitely, using layouts has many advantages. However, the only problem is that others can access my application's layout files, potentially steal them, and misuse them. Is there a solution for this?
 
Upvote 0

QSerg

Member
For quick development simple apps designer is indispensable. For ultimate flexibility and control you may wish to do it programmatically.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
However, the only problem is that others can access my application's layout files, potentially steal them, and misuse them. Is there a solution for this?
This is true no matter how you implement your UI. Whether it is a website, an app developed with Java/Kotlin or an app developed with B4X. Even if you implement your layout with assembler. How difficult is to steal the image files and copy the layout by hand?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
For quick development simple apps designer is indispensable. For ultimate flexibility and control you may wish to do it programmatically.
Can you give example of complex design that you wish to programmatically create it which layout file is very difficult to achieve?
Does it involve some kind of custom animation?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
There are such apps where one B4XPage\activity\window contains several containers that each should be filled with variable (and scrollable) layouts that also have containers for the next sub-layouts.
It's unthinkable to imagine how to do it without the Designer.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi, Which approach is better for implementing a user interface: direct coding or using Designer (layout)? Which method offers greater speed and is more standard? Furthermore, if the UI is implemented with a layout, is it possible for it and the .bal files to be decompiled and stolen? If so, how can this be prevented?

Which approach is better for implementing a user interface: direct coding or using Designer (layout)?
Ans: Designer (layout) + DSE + Anchors etc.

Which method offers greater speed and is more standard?
Ans: Designer (layout), WYSIWYG

if the UI is implemented with a layout, is it possible for it and the .bal files to be decompiled and stolen?
Ans: Yes, even if you write by code, once run your design can be copied (stolen). A screen-shot is enough for us to design similar layout, most of the time.

All these are already answered by members here, still I put it point by point, so that there is no confusion.
 
Upvote 0

QSerg

Member
Can you give example of complex design that you wish to programmatically create it which layout file is very difficult to achieve?
Does it involve some kind of custom animation?
I do not develop over-complicated animated apps. My apps rather static and simple from layout point of view. However they do include many different views (or pages, whatever you call them). When I tried to use pages in layout designer I found it over confusing and over-complicated. Thus I wrote few subs that hide/unhide, reposition and change dimensions of elements on the screen. So it is the same screen, but looks differently and re-utilize the same controls. I personally found this approach by far easiest. In B4A I greatly missing ultimate flexibility of forms and frames found in VB6 (or VBA) where without any fuss I can switch between them in any imaginable ways.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I do not develop over-complicated animated apps. My apps rather static and simple from layout point of view. However they do include many different views (or pages, whatever you call them). When I tried to use pages in layout designer I found it over confusing and over-complicated. Thus I wrote few subs that hide/unhide, reposition and change dimensions of elements on the screen. So it is the same screen, but looks differently and re-utilize the same controls. I personally found this approach by far easiest. In B4A I greatly missing ultimate flexibility of forms and frames found in VB6 (or VBA) where without any fuss I can switch between them in any imaginable ways.
We can't compare the era of VB6 with nowadays. These days, the UI design can be more complex. VB6 is too limited to produce such design today.
CustomListview is very powerful if you know how to use it.
Sometimes you just need to create a few more smaller parts layout to handle the dynamic layout.
Don't forget a panel can hold another layout and have another layout or views nested inside it.
For example, I have like 10 different layouts for my POS software where I can put the input pad on left, center or right.
I also can have tabstrip inside CLV that scroll vertically and horizontally where the tabstrip can load 4 page and 5 pages based on the number of weeks in a month, 7 days a week or 5 days if exclude weekends. All these will definitely difficult by writing code to draw them. Another thing it is very slow to load by doing a lot of calculation.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
a panel can hold another layout and have another layout or views nested inside it.

Long list of the sub-layouts that are being dynamically loaded into the containers. It's impossible to create by code, i can't imagine the hardness of the manual work...
Thanks to God Erel for the Designer.

1747113264482.png
1747113444441.png
 
Last edited:
Upvote 0
Top