Android Question Is it a bug or my limited understanding of layouts??

Small Petit

Member
Hello, I have two layout files and I loaded them like so:
B4X:
Activity.LoadLayout("Layout")
pnlMainPage.LoadLayout("content")

My main layout is just a panel centered on the screen as shown below:


And the content layout has the following arrangement:


Now, when I anchor Button1 to the bottom of the content layout, this is what I get as the end result:


And when I anchor it to the top, I rather get the following image as the output:


It seems the anchor is doing exactly opposite what I am expecting. Please is this a bug or I still haven't understood the concept of layouts well? Thank you.
 

Small Petit

Member
Moved to the questions forum. It is unlikely a bug.

Please upload the project with the button anchored to the bottom.

Tip: don't waste your time with activities. Switch to B4XPages.
Thank you Sir. I am very pleased to hear from you. I will switch to B4XPages as soon as possible....in that case I think there is no need to to upload the project. Thank you once again.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I think your anchor expectations are wrong. I assume that you want the SIGN UP button to be positioned in some fixed way relative to the other controls which are all anchored to the top, so the SIGN UP button should be top anchored as well, which in your example gives exactly the expected relative layout. I assume that layout is loaded into the panel in which case all looks well to me. What were you expecting to see?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I'm attaching... the worst I have managed to create! ?

At the beginning, the pnlMainPage is aligned well, in the center; it is blue. I wrote a Sleep (2000) to see this happen.

When I load the content, which has a transparent background, the Views go where they want and the blue of the panel "disappears".


[Right now I feel like a beginner?]
 

Attachments

  • LayoutTest.zip
    15.1 KB · Views: 127
Upvote 0

agraham

Expert
Licensed User
Longtime User
I think he wants the Button to be placed on the bottom of the container panel regardless of how tall it is.
In that case the button is wrongly placed in the layout. It should be be placed down at the bottom of the layout when anchored to the bottom with the number of pixels from the bottom being the required offset from the bottom of the panel.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I forgot to right align the Button. But... the color of the panel???
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I am attaching a second version that is only slightly better.

Views anchored at the top are actually automatically moved lower; it seems that this is due to the anchoring of the Button (on bottom).
I was forced to re-color the panel after loading it, despite the transparency of the content layout.
 

Attachments

  • LayoutTest2.zip
    15.1 KB · Views: 123
Upvote 0

agraham

Expert
Licensed User
Longtime User
Views anchored at the top are actually automatically moved lower; it seems that this is due to the anchoring of the Button (on bottom).
I don't think they are and it's nothing to do with the Button anchoring. You haven't put any text in Label1 so you can't see it. It is still at the top. The position of the others are scaled to absolute pixels by AutoScaleAll in the layout and then according to the dip scale value of the device as returned by GetLayoutValues. Comment out AutoScaleAll in the layout and then check the Top values. You will see they are the values in the layout multiplied by the device scale.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
WOW ! It can happen only at B4X Forum

The op did not put forth any reply or sample project but we have already found bugs and solutions to it
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I still don't understand the color problem, though.
It's late and I need to dash for dinner but I think the Panel adopts the layout colour when it is loaded so it becomes transparent to the underlying panel that is B4XMainPage and has the MainPage layout loaded into it. Give the MainPage layout a solid background colour and you will see it.
 
Upvote 0

Small Petit

Member
I just want the Button to be placed on the bottom of the container panel.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…