How can I change the parent of a view in the designer script?
I am building a screen where the horizontal buttons on a panel at the top of the screen in portrait view, will be MOVED (by changing their parent) vertically to a new/another panel at the side of the screen in landscape view.
I know I can do it in code, but I would love it done in the designer.
I would suggest you to define two layout variants.
One for portrait and a second one for landscape.
The views are the same but at different positions, the OS will load the correct one depending on the screen orientaion, therefore no need to move any view to another panel.
I actually have 2 variants, but it didnt work out.
1. For portrait mode, I have a panel (pnlTop) at the top of the activity. this panel hosts 2 buttons: btnOk & btnCancel. pnlRight is hidden at this point.
2. For landscape mode, I want a new panel (pnlRight) at the right hand of the activity. This activity should not host the 2 buttons above (btnOk & btnCancel). pnlTop is hidden at this point.
What I have observed is that I cant change a views parent in the variant. It will change for ALL variants.
Do you intent to move the 2 buttons from pnlTop to pnlRight.
No need.
In the landscape layout, move pnlTop to the righ, the same size as pnlRight and position the buttons as needed.