Android Question [Solved] Anchor not anchored at parent view?

Pflichtfeld

Active Member
Licensed User
In landscape view, I have two panels, each about half screen size.
In the left panel ('panelheader'), I have on top a spinner, child of panelheader, anchored to top and both sides (of panelheader)
In designercode I set
B4X:
PnlHeader.SetLeftAndRight(0,380dip)
but the spinner does not follow this measures. (380dip is just for testing)
Erel writes in his tutorial: "By changing the horizontal or vertical anchors we can set the position relative to other sides of the screen or parent view. "
In my case, the spinner seems to be anchored to activity-border, it keeps its width and does not react to change of panelheader.width.
What is wrong? what must I change?
(Situation:) anchors.jpg
 

Pflichtfeld

Active Member
Licensed User
Thank you Erel
Why??? Do it with anchors.
I have anchors for the panels as well. But I want to share the screen into two equal parts, so I have to do it in code, isn't it?
The layout is nested, and you tought me, not to use %x, %y in that case. I found no other way, to divide the (nested) layout, the two panels, in to equal parts without %x, %y.
Even if I would use %x, %y here, it would happen in designer script...
Is there a way else?
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
This was another case. It is now a layout with basicly two panels, loaded into another panel. I know I can do that by code in activitiy, but this hase no change to the anchor-problem of my spinner.
But no problem. I can size the spinner by code as well...
(The basic problem is, that the %-values in designer-script do not refer to the view, a layout is loaded in.)
Thank you!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Everything you wrote above is incorrect.

1. What I showed you in that post happens in the designer script.

(The basic problem is, that the %-values in designer-script do not refer to the view, a layout is loaded in.)
2. As you have been told many many times %x and %y do refer to the panel (or activity) that loads the layout.

About your layout, why is pnlFooter on the right side? My guess is that you should split your layout into three layouts. One with the two panels and another layout for each panel. Then everything will work as you expect.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
2. As you have been told many many times %x and %y do refer to the panel (or activity) that loads the layout.
Sorry Erel for my late response. I've been off for a few days. Thank you for your patience as well!!
My problem with this issue is, that in designer, %x and %y refer to the shown activity-size, but when it is loaded in a panel, it refers to that panel. Hope I grasped it now correctly.
Sorry for my stupidness...
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
And another point, which took me a time to understand, is the difference between nested views and loaded layouts into a view...
But to the origin of my question:
The anchors are applied right before the designer script is executed.
This is an important statement
 
Upvote 0
Top