Tool Designer Script Helper

tremara1

Active Member
Licensed User
I, like a lot of others have battled with the problem of the many screen sizes and densities in Android. I saw somewhere that if you use designer scripts with percentages of the variant size as for height, width and x,y positions then it should work on all screen sizes. This can be a bit of a chore if you have lots of views so I set out to make a tool (in B4j) to do the calculations for me. It got a little more complex than I originally planned but it seems to work so far. The accuracy is ok but I am working on getting it a little bit better. It uses sqllite to save it all. It is fairly straight forward the important thing is when you enter the view name that it is entered accurately as this is used in the script. I have set it to use the standard 320 x 480 variant(portrait) and 480 x 320 (landscape) as the default I may add ability to use different sizes later you can either use the script for all variants if you have a simple layout or you can create a script for portrait and landscape and put the script in variant specific section.
All you do is create the layout as you want (one variant for portrait and one for landscape) and then use this tool and enter all the views width, height, left, top for that layout the script is created and you copy and paste it in the designer.
I did a couple of small videos(no audio) showing usage at:

https://tremara1.tinytake.com/sf/ODE1MzdfNTYyNDYz

https://tremara1.tinytake.com/sf/ODE1NDlfNTYyNTY5

The download is here : https://www.dropbox.com/sh/m28uwc69wc37ucm/AADmqCZ8GH5DIR8_S-ethgCUa?dl=0

I will upload the b4j project when I have cleaned up my code and commented it.

Very early in development so I would be careful and work with copies of your important projects to see how it works.

There is some rubbish data in the app I used for testing.
 
Last edited:

LucaMs

Expert
Licensed User
320x480 is a resolution of old devices. I would start with a higher resolution, in this way you can enter a larger number of views.

Furthermore, the percentages should be decimal numbers.

upload_2015-3-8_0-48-0.png
 
Last edited:

NJDude

Expert
Licensed User
320x480 is a resolution of old devices. I would start with a higher resolution.
That is not correct, that's the base resolution, all variants are based on that.

Furthermore, the percentages should be decimal numbers.
That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example.
 

LucaMs

Expert
Licensed User
That is not correct, that's the base resolution, all variants are based on that.
What means "base resolution"? Nothing, especially in the @tremara1's project, because in it he calculates the percentages.

Furthermore, in a screen that has the resolution so low you can put a few views and now there are no more devices which have that resolution.


That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example.
There is not half pixels but decimal numbers are essential, of course.

In that example:

txtClose.Top = 3% = 9.6
txtClose.Top = 3.750% = 12 (the desired distance)
 
Last edited:

tremara1

Active Member
Licensed User
I have updated so percentages are 3 decimal point values....I am working on adding the ability to enter your preferred "base" screen size so you can have as much screen real estate as you want. I also note that I need to adjust the text size of views with text. I see there are already tools for this.
 

tremara1

Active Member
Licensed User
I have updated the app. Link is in the first post. It now has all the standard variants available. If you have used the original version you will have to use the new db file as some changes were made(sorry). I must say this is not for everyone as it does not work if you use a device as the designer it really is for us who use the abstract designer. I have noted the abstract designer actual height is not the same as the variant height caused accuracy problem so I have put a small adjustment to account for this. If anyone tries this and finds the top value not accurate I would be pleased if you could reply with the (actual) abstract designer height (I used a panel set to the abstract designer height to measure) and which variant used in your set up. I take this opportunity to remind that the variant size in this app must match the variant size in your designer. The big advantage for me was only 2 variants are needed. I have tried the outcome on 3 devices and it seems to work. I doubt this is the 100% answer for all screens so some adjustment may still be needed in some cases. Hope it is helpful. Also the videos do not show the new version.
 
Top