I believe I have read all that I could on this forum about properly scaling the display and I am not yet where I want to be, still thoroughly confused....
My layout is pretty simple (for now) and all I want (for now, baby steps...) is properly spacing and scaling a few buttons and labels across the width of the display on different devices.
I am at the point where all the views, consisting of buttons, labels and listviews, are scaled in dip as a function of a single variable (that I called "width" and is declared in dips) and as long as I manually set the "width" parameter in my program for a given tablet, everything is laid out just fine. I use 3 devices at the moment, two are rated 7" and one is 8".
The two 7" tablets actually have the same physical width (not just the vendor's rating, I measured it and they are exactly the same physical size, height and width) but different DPI, so I assumed they would have the same width in dips but for everything to look the same, in the following code I have to set the "width" parameter to 435dip and 550dip respectively (note that "width" is not the actual full width of the display, I have about 1/4" margin on each side on purpose). That's a big difference! Needless to say, without adjustment, it just looks wrong.
Assuming 1 dip is based on 160DPI, that would mean that one device is 2.7" wide while the other is 3.4". They both are exactly 3.6" wide.
I am not using the "Scale" parameter that I have seen mentioned many times as I have not found where to declare it or how to set it.
Here is an example of what I mean:
I guess the question is how can I find how wide is my screen in dips?
I also use 100%x to set the width of a ListView and that seems to work, but I saw some strongly worded opinions on this forum against doing that for all views.
It would probably work better if I centered everything, the difference would not be as noticeable as with everything left anchored, but I would prefer that it scaled properly.
Thanks in advance for any suggestion...
My layout is pretty simple (for now) and all I want (for now, baby steps...) is properly spacing and scaling a few buttons and labels across the width of the display on different devices.
I am at the point where all the views, consisting of buttons, labels and listviews, are scaled in dip as a function of a single variable (that I called "width" and is declared in dips) and as long as I manually set the "width" parameter in my program for a given tablet, everything is laid out just fine. I use 3 devices at the moment, two are rated 7" and one is 8".
The two 7" tablets actually have the same physical width (not just the vendor's rating, I measured it and they are exactly the same physical size, height and width) but different DPI, so I assumed they would have the same width in dips but for everything to look the same, in the following code I have to set the "width" parameter to 435dip and 550dip respectively (note that "width" is not the actual full width of the display, I have about 1/4" margin on each side on purpose). That's a big difference! Needless to say, without adjustment, it just looks wrong.
Assuming 1 dip is based on 160DPI, that would mean that one device is 2.7" wide while the other is 3.4". They both are exactly 3.6" wide.
I am not using the "Scale" parameter that I have seen mentioned many times as I have not found where to declare it or how to set it.
Here is an example of what I mean:
B4X:
Dim width as Int
width = 435dip ' use 550dip with other 7" tablet
lblPage1.Width = width ' label that goes across
edittxtIP.left = width - edittxtIP.width ' an edittext box that is anchored to the right (fixed size label on left)
lblSocketStatus.Left = width - lblSocketStatus.Width ' same thing with a label
' the next line has a fixed label on the left, a checkbox and a progress bar anchored to the right
pbADC1.Left = lblADC1.Left + lblADC1.Width + 10dip + chkADC1.Width + 10dip ' width - pbADC1.Width
pbADC1.Width = width - pbADC1.left
I also use 100%x to set the width of a ListView and that seems to work, but I saw some strongly worded opinions on this forum against doing that for all views.
It would probably work better if I centered everything, the difference would not be as noticeable as with everything left anchored, but I would prefer that it scaled properly.
Thanks in advance for any suggestion...