Mar 7, 2015 Replies: 8 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: Mar 11, 2015 Click to expand...
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.
LucaMs Expert Licensed User Longtime User Mar 7, 2015 #2 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. Last edited: Mar 7, 2015
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.
NJDude Expert Licensed User Longtime User Mar 8, 2015 #3 LucaMs said: 320x480 is a resolution of old devices. I would start with a higher resolution. Click to expand... That is not correct, that's the base resolution, all variants are based on that. Furthermore, the percentages should be decimal numbers. Click to expand... That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example.
LucaMs said: 320x480 is a resolution of old devices. I would start with a higher resolution. Click to expand... That is not correct, that's the base resolution, all variants are based on that. Furthermore, the percentages should be decimal numbers. Click to expand... That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example.
tremara1 Active Member Licensed User Longtime User Mar 8, 2015 #4 LucaMs said: 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. View attachment 32738 Click to expand... Yeah... I will tighten it up shortly
LucaMs said: 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. View attachment 32738 Click to expand... Yeah... I will tighten it up shortly
LucaMs Expert Licensed User Longtime User Mar 8, 2015 #6 NJDude said: That is not correct, that's the base resolution, all variants are based on that. Click to expand... 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. NJDude said: That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example. Click to expand... 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: Mar 8, 2015
NJDude said: That is not correct, that's the base resolution, all variants are based on that. Click to expand... 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. NJDude said: That's also not accurate, those values can vary and regarding decimals, there's no such thing as "half a pixel" for example. Click to expand... 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)
tremara1 Active Member Licensed User Longtime User Mar 8, 2015 #7 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.
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 Longtime User Mar 13, 2015 #8 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.
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.