Designer view width height 100%

rstewart

New Member
Licensed User
Longtime User
Is it possible to set a view to 100% of the parent in Designer?

I used -1 width and -1 height as suggested by another post.

However, the designer collapses the view to 0x0 ad shows just the red handles overlapping each other. I would like to see the real 100% view in Designer.

Woud rather have designer fit it to the screen or parent container.
 

cammel8

Member
Licensed User
Longtime User

cant you set it programatically by doing something like :
activity.AddView(View_you_need_to_be_Full_size,0,0,100%x,100%y)
or if you are using a panel as the parent cant you do
activity.AddView(View_you_need_to_be_Full_size,0,0,panel1.width,panel1.hieght)

I'm just thinking out loud here but that is what i would try first.
 
Upvote 0

bergapappa

Member
Licensed User
Longtime User
Good way to dynamically size stuff

I've just been trying to size my view dynamically instead of using different layout, just lazy I guess. I have an simple Portrait app.

I started declaring 2 varibles Ax and Ay.
Then I set:
Ax = activity.Width (I use the activity, but I guess it could be any object)
Ay = activity.Height

Then just use them giving your views sizes.
Ex. for my image view "imgbak" that is a square image
imgbak.Height = Ax-20
imgbak.Width = Ax-20
imgbak.Left = 10
imgbak.Top = Ay-Ax
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
If I have a panel of which the parent is the main activity and then add a button to this panel and declare the panel as the parent of the button, should the button then not be located at a distance of 5% (relative to the height of the panel) from the top of the panel when I use the following designer script:

Button1.height = 5%

Seems not to be the case?
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
No. It should set te height to 5% of the panels height.
If you want to change it position you can use Button1.Top = 5%y
Sorry, typing error. I meant 5%y. The button does not follow 5%y of the height of the panel despite the fact that its parent was declared as the panel and not the activity. The top seems to be at 5%y of the activity - not 5%y from the top of the panel. I am obviously doing something wrong...
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Johan,
as you verified 5%y means 5% of activity's height.
If you want to place your button top at 5% parent's height you should set:
Button.Top = OwnerPanel.height / 20 ' or multiply by 0.05

udg
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,
as you verified 5%y means 5% of activity's height.
If you want to place your button top at 5% parent's height you should set:
Button.Top = OwnerPanel.height / 20 ' or multiply by 0.05

udg

The designer scripts just does not make sense to me whatsoever. See lines 24 to 27 of the designer script of the attached project. Where did BtnSto disappear to when the project runs on a device? It is very very frustrating...

And when I block lines 24 and 26 of the designer script everything changes and suddenly the button decides to appear? Can we please have some clarity on how this is suppose to work. Seems like one has to spend way more time on trying to sort out a layout than on writing code...
 

Attachments

  • JHS_RPN_CALC_V3.zip
    387.5 KB · Views: 233
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Seems like one has to spend way more time on trying to sort out a layout than on writing code
You are not forced to use this feature. You can adjust the layout in your code if you like.

It will not matter in this case as the bug in your designer script will behave in the regular code exactly the same.



B4X:
BtnSto.Left = Panel3.left
BtnSto.Top = Panel3.top + 5%y
BtnSto is a child of Panel3. Its coordinates are relative to its parent coordinates.
If you want the button to be 5%y from the top of the panel you need to write:
B4X:
BtnSto.Top = 5%y
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…