B4J Question setsize doesn't work

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello,
I am trying to set the size of a pane, at runtime, but for some reason it doesn't work.
what am I doing wrong ?


B4X:
    ' ResolutionX and ResolutionY contain the screen and mainform resolution
    ' Caixa1 is a Pane created via Abstract Designer
    Dim SizeX as Double = ResolutionX / 5
    Dim SizeY as Double = ResolutionY / 5
    Caixa1.Top=0
    Caixa1.Left=0
    Caixa1.SetSize(SizeX,SizeY)
 

PatrikCavina

Active Member
Licensed User
Try to use:
B4X:
Dim SizeX as Double = ResolutionX / 5
Dim SizeY as Double = ResolutionY / 5
Caixa1.Top=0
Caixa1.Left=0
Caixa1.PrefWidth = SizeX '<-----
Caixa1.PrefHeight = SizeY '<-----
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
Log SizeX and SizeY, to watch if are always the same value. Maybe the mistake is in resolution calculation

Nope. Not even checking the width and height in the designer and doubling it in the code.

Designer = 250 x 150
B4X:
Caixa.Setsize(500,250)

Stays the same
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
How you calculate ResolutionX and ResolutionY?

I use this code

B4X:
Dim joForm As JavaObject = MainForm
joForm.GetFieldJO("stage").RunMethod("setMaximized", Array(True))
ResX=MainForm.Width
ResY=MainForm.Height

But as I wrote previously, even setting the size with fixed values doesn't resize
 
Upvote 0
Top