Android Question [Solved] I cannot understand the way, different layouts work together

Pflichtfeld

Active Member
Licensed User
I cannot cope with this designers- and panel-transparency logic
I would expect such a screen:
test.png
But it never comes. The red panel does not appear, whatever I try.
Can anybody please explain me, what is wrong?
 

Attachments

  • test.zip
    9.7 KB · Views: 280

Erel

B4X founder
Staff member
Licensed User
Longtime User
Designer drives me mad with transparent panels
Such statements doesn't encourage me to help you however I will do it this time.
The problem is in your designer script and has nothing to do with transparent panels.

Run the designer script in the designer and you will immediately see that Panel2t disappears. It happens because it is inside Panel2 and 50%y is relative to the activity in this case.

I recommend you to make the layout simpler and not nested like this.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
Such statements doesn't encourage me to help you however I will do it this time.
Run the designer script in the designer
It happens because it is inside Panel2 and 50%y is relative to the activity in this case.
I recommend you to make the layout simpler and not nested like this.
Thank you Erel. First I apologize for the title of the posting: It was the result of dealing with Layouts for HOURS to understand the idea layers work and not coming to a solution.
It is still most inscrutable for me and it all does not work as I expect.

In my understanding and what you explain here L2 changes by loading in Panel2t its relation to panel2t. That is what I would expect:
Layers.png
I would expect to still see panel2, because I load into a transparent panel2t, but only the upper half of panel2 is visible, because the lower half (50%y of panel2t) is covered by panel4. But I don't get the expected result: panel4 is not visible at all. WHY?

I know, this layouts are not simple, but I am testing to understand how layouts work and panels function. And I hoped, that they work the way I understood the whole stuff, but they don't (what drives me mad ;)).
So. What would be the correct layouts to reproduce an effect as I wished and described.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
50%y of panel2t
That's the mistake. %x and %y in the designer script are relative to the size of the panel or activity that loads the layout. Note that in the code %x and %y are always relative to the activity size.
You can easily see that your panel disappears by click on the "run" button in the designer. Try it.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
Thank you for your patience Erel!
That's the mistake. %x and %y in the designer script are relative to the size of the panel or activity that loads the layout.
You can easily see that your panel disappears by click on the "run" button in the designer. Try it.
It seems that I am totally blocked or we do not understand each other:
I actually work with TWO layouts. layout2(L2) is loaded into panel2t of layout0 (L0). So all views from L2 should shrink proportionally to fit panel2t.
50%y in designerscript in L2 for panel4 should be 50% of panel2t after loading panel4 into panel2t what means that panel4 (in layout L0) has 25%y of activity-size (50% of 50%).
and:
None of my panels in none of the two layouts disappear, when I click the run-button in designer.
 
Last edited:
Upvote 0

Pflichtfeld

Active Member
Licensed User
Why exactly do you believe that you need 2 layouts?
Thank you, Peter!
Your example is easy to understand and I have no question about it. But it does not what I want:
I want to have 2 layouts because I am planning to port app with different activities (it former was a VB.NET-Projekt) to android. Each activity should have the same "Basis-Layout" that means, it has views which should be present in every activity.
But each activity has special tasks to execute with activity-special views. So I thought it to be a good idea, put the particular views in particular layouts and load in each activity the main-layout and then into a panel of layout main the particular layout.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Well, I will try to explain what is wrong in your layout.
On L0 you have 3 Panels:
Panel1 full screen.
Panel2, is a child of Panel1 and covers the bottom half part of the screen.
You set Panel2.SetTopAndBottom(50%y, 100%y), which is OK.
Panel2t, is a child of Panel2 with the same size. And you set it with:
Panel2t.SetTopAndBottom(50%y, 100%y), which is wrong !!!
Because the reference of the top coordinate of Panel2t is Panel2!!
You set the Top property to 50% which is the height of Panel2, therefore you won't see it because you moved it of the size of Panel2!!!
You should set Panel2t to:
Panel2t.SetTopAndBottom(0%y, 50%y)
And now you will see it. To test it, set the color of Panel2t not transparent.
Layout L2 is OK because you set the top and bottom values.
Panel4.SetTopAndBottom(50%y,100%y)
Because you want it to cover only the bottom half of Panel2 (Panel2t).

Then the reason, why you did need to add a transparent panel Panel2t on top of Panel2 with the same dimensions is!
Without Panel2t, when you load L2, which has a transparent background it set the background of Panel2 to transparent.
You set Panel2t to transparent, but the transparency of Panel2t at the end doesn't come from the background you set, but from the background of layout l2.
Set the background of Panel2t to any non transparent value and it works the same.

But, anyway, I didn't understand what exactly you want to do.
Now, with your explanation in post#10 I understand better.
Your approach looks very complicated to me.
I would work with one Activity and Panels and show or hide the Panels depending on the different cases.
Or, maybe use classes.

While I was writing I saw there were already some other posts, but I thought I finish it.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Because the reference of the top coordinate of Panel2t is Panel2!!
You set the Top property to 50% which is the height of Panel2, therefore you won't see it because you moved ot of the size of Panel2!!!
You should set Panel2t to:
Panel2t.SetTopAndBottom(0%y, 50%y)
I think he wanted Panet2t height 50%y of Panel2 (already set to 50% of its parent by script) at bottom of Panel2.
1586180764773.png

and, as you can see, it works using 25%y and 50%y, which is strange, since...
%x and %y in the designer script are relative to the size of the panel or activity that loads the layout
Because the reference of the top coordinate of Panel2t is Panel2!!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
think he wanted Panet2t height 50%y of Panel2 (already set to 50% of its parent by script) at bottom of Panel2.
In that case it should be:
B4X:
Panel2t.SetTopAndBottom( Panel2.Height / 2, Panel2.Height)

Don't use %y here as the %y refers to the Activity height. The layout is loaded to the activity.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
You need to do a single change to fix the layout.
Change:
Panel2t.SetTopAndBottom(50%y,100%y)
To:
B4X:
Panel2t.SetTopAndBottom(0, Panel2.Height)
That is weird, but I understand it, thank you again!
Maybe I missunderstood what you wrote here:
25%x means a quarter of the activity width. Not the parent.
There is one exception. %x / %y in the designer script are relative to the main parent which is the view that loads the layout.
As far, as I understood, this is:
When
B4X:
Panel2t.LoadLayout("L2")
in Activity_create is executed, then x% and y% are relative to the view, the layout is loaded in. In designer it always refers to activity, not to the parent.
But obviously even in designer it seems to be the parent, not the activity!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I think he wanted Panet2t height 50%y of Panel2 (already set to 50% of its parent by script) at bottom of Panel2.
No, he put Panel2t onto Panel2 because of the transparency!
At least, that is how I understood it, because he wrote somewhere that he had to add a transparent Panel to get his layout to work.
 
Upvote 0
Top