how to create this layout?

barx

Well-Known Member
Licensed User
Longtime User
Sorry about the non-descriptive title, but I couldn't think of anything else.

I am creating an app and want it to look different on phone and tab. Was thinking of doing 2 apk's. One for each but going to try it in one first to keep fragmentation down.

Phone layouts - no problem and an example is below and works well on tested devices.
example layout.jpg

and example of a screen selected from the menu is (note this isn't finished before anybody thinks it looks bad :)):
toolscreen.jpg

Now due to the nature of the layout I think it will look rubbish to simply blow it up. So my idea is to move the listview (menu) into a sidebar (Panel) and shown the content selected from the menu in a Content panel. see below for layout

Tablet-Split.jpg

Now my idea was to add a panel (pnlWrapper) with pnlContent as its parent, use pnlWrapper.LoadLayout to insert the selected screen, which will hopefully be a reasonable size once I figure the AutoScaleRate. Then once the layout is loaded center up the wrapper panel on the content panel.

What would be the best way to go about this, tried a few things but cannot get the required results. Ideally the selected screen would fill the screen height wise and then size the wrapper panel width to the required width to suit the height. then display center.

Hope this makes sense. Look forward to some replies.

Cheers
 

barx

Well-Known Member
Licensed User
Longtime User
it appears that what I am trying to do is 'Fragments'

It appears that b4a doesn't support the native fragment, but I am trying to build something similar in code.

Blowing my mind at moment.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Now my idea was to add a panel (pnlWrapper) with pnlContent as its parent, use pnlWrapper.LoadLayout to insert the selected screen, which will hopefully be a reasonable size once I figure the AutoScaleRate. Then once the layout is loaded center up the wrapper panel on the content panel.
Sounds like a good solution.

You can check the return value of Activity.LoadLayout. If it returns the tablet variant then you should load the second layout to the panel.

You can set pnlContent.Visible to False in the phone variant.
 
Upvote 0
Top