Need advice: Should I use a Layout?

Widget

Well-Known Member
Licensed User
Longtime User
I have a simple app that has a navigation panel at the bottom of the screen with buttons on it and a seekbar. The panel takes up maybe 15% of the screen height and occupies the full width of the screen. The rest of the screen contents are generated at runtime when the user clicks on the panel buttons. The panel will have 3 "pages" where each page has a different set of views displayed.

So far I have used the Designer to design the app, which only has the panel in it. The contents of this panel will change (different views will be displayed on the panel) when the user presses the forward or back buttons (this also updates the main activity window using code).

My question is:
1) Do I use the Designer and design 1 layout for the app and hide/unhide the views on this panel using code? This could get messy because the Designer will have a dozen views on it, 60% of them will be hidden at runtime.

2) Do I use the Designer and design a panel for each page of this navigation panel and load the correct layout into the panel?

3) Do I design the panel using code and forget about the Designer altogether? This allows me to control the positions and widths of the views on this panel using code so it fits on any Android device.

Any advice would be appreciated. If someone can point me to documentation or a working example, that would be great too. ;)

Widget
 

Brad

Active Member
Licensed User
Longtime User
I use the #2 approach and would recommend it for that number of views.
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
I use the #2 approach and would recommend it for that number of views.

Ok, thanks for the feedback.

1) Would I still need to create layout variants with the Designer for each panel?
2) Or would I handle the positioning of the views within each panel using code when the panel layout is loaded? (easier for me)

Widget
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I have an app that has a quite few layouts, and after trying to keep up with all the possible layout variants required, I now tend to use the designer, create just one variant and have at least two panels for each layout.

One is just a background panel (that also serves to block clicks on panels below it) which I size in code to the size of the screen for the current device.

The second panel is where I add the views, the size of which I don't normally change per layout. Then I centre the panel on the screen (or in the background panel) using code once the layout is loaded.

The second panel has to be small enough to fit on the screen of the smallest device you want it to display on properly.

Occasionally I need to juggle the layouts and the odd layout has two or three variants, but it keeps the work to a minimum.

I find this works fine for most cases.

Steve
 
Upvote 0
Top