Android Question How to get needed Panel DImensions?

Guenter Becker

Active Member
Licensed User
Hello,
today I have a question that knocks my head.
Lets say I have this code:
Dim P as Panel
P.initialize("")
P.loadlayout("ABC")

This leads me into the problem that the layout is not shown correct because the panel dimension have to be set prior loading.
Due to the fact that the layout dimension are depending on the used device and are not set automated after loading the layout there is the question how to get the needed panel dimensions before loading the layout.
May be this question is silly but yet I'm lost.

Anyone able to help me?
Thank you in advance
 

LucaMs

Expert
Licensed User
Longtime User
You know the views that are part of the layout.
I would say to consider the minimum and sufficient dimensions for each type of view; for example, it is reccomended to make them at least 40/50 dip high.
By then you should know the minimum panel size you need.
 
Upvote 1

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
This is actually quite a complicated question which has several solutions depending on how the layout is constructed.

There are (broadly) 2 types of layout:
  1. Fixed size , where the size of the layout does not vary ( left-right ,up-down anchors are not used)
  2. varying size, where the size of the controls in the layout, is dependant upon the layout container

Solution for 1:
B4X:
    p.Initialize("")
' Some arbitary size
    p.SetLayoutAnimated(0,0,1000dip,2000dip)
    p.LoadLayout("ViewEntrySingle")

    p.Height = control.top + control.height ' this control is a control at the bottom of the layout
    p.width = control.left + control.width ' this control is on the right of the layout


Solution for 2
For 2, you need the to know the container size (sometimes root for b4xpages)
then
B4X:
    p.Initialize("")
    p.SetLayoutAnimated(0,0,root.width,root.height)
    p.LoadLayout("ViewEntrySingle")

Finally, you may need a panel which can vary in only one of the dimensions.

If you look at the last post in this thread


and the code for resizingTextControl you can see how this is done.

EDITS: Pressed send too early.
 
Upvote 0
Top