Java Question AutoSize Library

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello everyone,

This was just a test for a project where all of the views would be automatically resized to the screen resolution of the device.

It is based on this excel document sheet (I cannot find the topic and author anymore.) where you have to enter the top, left, width, height and x/y positions and it generates you text where you have to copy and paste it to resize your views. (It's included in the zip file.)

But my library will do it all automatically.
It was basically a test on how far my java is as I am actually new at this.

But still, my library still contains a bug that I cannot solve or find.


B4X:
Sub AutoSize_ResizeViews (Number As Int, Left As Float, Top As Float, Width As Float, Height As Float)

Select Number
    Case 1
   'view 1 (Got this number from AutoS.getViewId)
        ScrollView1.SetLayout(Left*1%X, Top*1%Y, Width*1%X, Height*1%Y)

    Case 2
        imgView.SetLayout(Left*1%X, Top*1%Y, Width*1%X, Height*1%Y)
    Case 3
        Button1.SetLayout(Left*1%X, Top*1%Y, Width*1%X, Height*1%Y)
   Case 4
        Msgbox("4","") 'not called because there are no more views.
End Select
End Sub

In setLayout, I don't know how to combine the Left togheter with the "%X" like it is shown here:

B4X:
imgLogout.SetLayout(6.25%X,31.25%Y,12.0833333333333%X,18.125%Y)

suggesting Left = 6.25, Top = 31.25, ...

Another thing, is that if I know the code for setLayout in Basic4Android, I can remove the Sub AutoSize_ResizeViews and automatically do it in the library.
This way all the views will be resized with just one line of code in Basic4Android.

I hope you can help me out with this

Thanks,

XverhelstX
 

Attachments

  • AutoSize Library.zip
    318.2 KB · Views: 394
Last edited:

NeoTechni

Well-Known Member
Licensed User
Longtime User
Please start a new thread for this question (in the Questions subforum).

But then you dont have a guarantee the dev will see it. It's better to keep all questions in one topic. Then you dont get multiple people asking the same question too
 
Top