Not a bad idea at all. Actually this thing has been covered, you can search in the forum, there are posts available, you can even find Erel's solution to this problem. Of course, you can deal with relative positioning, after all, this is what %x and %y used for in views' dimensioning.This may be a dumb idea, but isn't there a way to do this adjusting mathematically from within the app? What I'm thinking of is an initial layout where the resolution and density is known and where the positions and sizes of the objects are known in relation to this initial layout. Then being able to determine the actual resolution and density of the actual device and calculate the positions and sizes of the objects as a ratio between the initial layout and the actual layout. Or am I oversimplifying?
ScrollViewInformation.SetLayout(0%X,25%Y,65.625%X,41.6666666666667%Y)
ImageViewPhoto.SetLayout(0%X,66.6666666666667%Y,65.625%X,33.3333333333333%Y)
Re my previous post on this topic: what 'Android' seems to do is recalculate (at runtime) the position & size of a view according to the device's characteristics but 'optimises' them in some way such as using the same actual/variant ratio for both vertical & horizontal. Thus, the Left/Top/Width/Height properties are changed at runtime. This makes it difficult to replace the spreadsheet by B4A coding. So I've given up on dispensing with the spreadsheet.
View1.Left = 10dip
View1.Width = 200dip
View2.Left = View1.Left + View1.Width
View2.Width = 200dip
View1.Left = 5%x
View1.Width = 50%x
View2.Left = View1.Left + View1.Width
View2.Width = 40%x
There have been several posts regarding designing layouts for multiple screen sizes and densities. Specifying view locations in terms of %X and %Y is one such approach which will adapt to any screen. The result may not be optimized visually, but at least it should work on any device.
For most projects, I use the visual designer to layout the various views. Converting multiple views to relative positions can be quite tedious, but here is one method to speed the process (I used this method to update my ProbCalc program located in the Share Your Creations forum):
I used the visual designer to layout all of the views (I used 320 x 480 scale=1).
In Excel (or similar spreadsheet) I created a row with 5 columns containing "Name L T W H".
I then entered the name of each view along with its L T W H values.
I then added 4 more columns labeled "X Y X Y".
For each row (view) I had Excel divide each view's layout values by either X (320) or Y (480) (multiplied by 100 to yield the relative percentages).
Then using Excel's Concatenate fuction I generated the appropriate SetLayout string for each view.
Finally, I pasted these strings into my program in a sub called "ResizeViews", which is called from the sub Activity_Resume.
Because I wanted different portrait and landscape views, I repeated the process for the alternate layout.
It sounds a lot more complicated and time consuming than it really was. Inspect the attached spreadsheet and I think you will see.
There have been several posts regarding designing layouts for multiple screen sizes and densities. Specifying view locations in terms of %X and %Y is one such approach which will adapt to any screen. The result may not be optimized visually, but at least it should work on any device.
For most projects, I use the visual designer to layout the various views. Converting multiple views to relative positions can be quite tedious, but here is one method to speed the process (I used this method to update my ProbCalc program located in the Share Your Creations forum):
I used the visual designer to layout all of the views (I used 320 x 480 scale=1).
In Excel (or similar spreadsheet) I created a row with 5 columns containing "Name L T W H".
I then entered the name of each view along with its L T W H values.
I then added 4 more columns labeled "X Y X Y".
For each row (view) I had Excel divide each view's layout values by either X (320) or Y (480) (multiplied by 100 to yield the relative percentages).
Then using Excel's Concatenate fuction I generated the appropriate SetLayout string for each view.
Finally, I pasted these strings into my program in a sub called "ResizeViews", which is called from the sub Activity_Resume.
Because I wanted different portrait and landscape views, I repeated the process for the alternate layout.
It sounds a lot more complicated and time consuming than it really was. Inspect the attached spreadsheet and I think you will see.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?