Tool for automatic calculation setLayout.

anallie0

Active Member
Licensed User
Longtime User
Hi

I recently started programming with basic4android, and for the resolution management using the setLayout function. to speed up the calculation of the percentage, I wrote a program in excel that calculates all 4 variables and inserts them into the clipboard. So it is sufficient that you write the name of the object and then press Ctrl + V.

:)
 

Attachments

Thanks for writing this tool.

I am in the process of coding the percentage sizes and positions of all my views. Its taking a lot of time because of all the trial and error. Your tool is going to save me a lot of time.

Is there a way to implement your calculator code from within a B4A app, so that views can be placed where you want them on your default Layout Variant and then they would automatically resize and position themselves on other devices with different resolutions?
 
Upvote 0
It took me a short while to convert your Excel code to B4A. My hope is that the code will resize every view in the activity automatically, regardless of the resolution. I haven't got another device to test it on and I don't know if there are any reasons why I shouldn't take this approach, but here is what I got so far...(please note that I have one little thing to fix before its usable, see below)

Code: Copy
Sub Set_Layout()
   Dim L,T,W,H As Int   
   Dim Result As String
   Dim CurView As View
   
   For i = 0 To (Activity.NumberOfViews-1)
      CurView=Activity.GetView(i)
      
      L = (CurView.left * 100 / Activity.Width)
      T = (CurView.Top * 100 / Activity.Height)
      W = (CurView.Width * 100 / Activity.Width)
      H = (CurView.Height * 100 / Activity.Height)
      
      Result=L & "%x, " & T & "%y, " & W & "%x, " & H & "%y"
      Activity.Title=Result
                
      CurView.SetLayout(L & "%x", T & "%y", W & "%x", H & "%y")
   Next
End Sub
LTWH have the correct values but I'm having a little difficulty combining them with "%x" or "%y" in the CurView.SetLayout statement.
 
Upvote 0
...Is there a way to implement your calculator code from within a B4A app, so that views can be placed where you want them on your default Layout Variant and then they would automatically resize and position themselves on other devices with different resolutions?

I've made this little app in vb6 which do it
 

Attachments

Upvote 0
Thanks for the useful feedback. The SetLayout statement works now but the result wasn't exactly what I had hoped for. It's nearly Midnight and I'll wait until tomorrow to work on it some more.
 
Upvote 0
Timo,
Cool app in VB.

I might just be reinventing the wheel. But at least I'm learning stuff along the way.
 
Upvote 0
see note below
 

Attachments

  • SetLayout2.jpg
    SetLayout2.jpg
    73.7 KB · Views: 923
Last edited:
Upvote 0
Back
Top