Designer with 240 density

jschuchert

Active Member
Licensed User
Longtime User
I am really embarrassed for bringing this up again but I have been away from it for a couple of weeks and my brain is still in sleep mode.

I "think" I finally found out why my device is not displaying my app properly (views are off the screen). My tablet has a density of 240 (scale=1.5) and the designed layouts were done with 160 (scale =1). So if I want to make layouts compatible with a density of 240, is this the way to do it:
name a new emulator
Same target of android 2.2 (API level 8)
Skin of HVGA
Resolution of 480x800
SD Card =16
abstracted lcd density=240
Create the emulator
Start
Scale display to real size=7
Monitor dpi=72
Scale 0.54 (???)

I think I was doing this before but using density of 160 and it wasn't fitting my tablet. Should have a Toshiba Thrive by early next week for the 10" version.

I will do some test layouts to make sure this works.

Jim
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
I am really embarrassed for bringing this up again but I have been away from it for a couple of weeks and my brain is still in sleep mode.

I "think" I finally found out why my device is not displaying my app properly (views are off the screen). My tablet has a density of 240 (scale=1.5) and the designed layouts were done with 160 (scale =1). So if I want to make layouts compatible with a density of 240, is this the way to do it:
name a new emulator
Same target of android 2.2 (API level 8)
Skin of HVGA
Resolution of 480x800
SD Card =16
abstracted lcd density=240
Create the emulator
Start
Scale display to real size=7
Monitor dpi=72
Scale 0.54 (???)

I think I was doing this before but using density of 160 and it wasn't fitting my tablet. Should have a Toshiba Thrive by early next week for the 10" version.

You said that your tablet has a density of 240, yet in your specs above, you indicate that your device is 7" and has a density of 800x480. That is a density of 160, not 240. The Thrive also has a density of 160. Only a small device, i.e.: a phone, could have a resolution of 800x480 and a density of 240.

In addition to the factors you listed, you should also be aware that many tablets use part of the screen for the soft menu buttons. On the Thrive, it's at the bottom of the screen, so in landscape mode, for example, the resolution will not be 1280x800 but 1280x776. On an Archos 70, the menu is on the right so that instead of 800x480, its resolution is 760x480. The only way to adjust for such differences is in Activity_Create.

For example, in an app I'm working on, I have a segment like this (where "LayoutHeight" is the value used in the emulator, such as 800):

B4X:
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]' Adjustment for tablets whose menu bar is at the [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]' bottom [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]of the screen in landscape mode:[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] LayoutHeight <> Activity.Height [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] AdjustUp = (LayoutHeight - Activity.Height) / [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ExplainPanel.Top = ExplainPanel.Top - AdjustUp[/SIZE][/FONT]
[SIZE=2][FONT=Courier New] ScorePanel.Top = ScorePanel.Top - AdjustUp[/FONT][/SIZE]
[SIZE=2][FONT=Courier New] PlayerNums.Top = PlayerNums.Top - AdjustUp[/FONT][/SIZE]
[SIZE=2][FONT=Courier New] LabelDetail1.Top = LabelDetail1.Top - AdjustUp[/FONT][/SIZE]
[SIZE=2][FONT=Courier New] LabelDetail3.Top = LabelDetail3.Top - AdjustUp[/FONT][/SIZE]
[SIZE=2][FONT=Courier New] panelCards.Top = PanelCards.Top - AdjustUp[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
For more info, see this page in the Documentation Wiki.
 
Upvote 0

jschuchert

Active Member
Licensed User
Longtime User
Further information:
With the bridge connected to device, I entered the following (results are shown in red):
B4X:
Dim dens As Float
Dim lv As LayoutValues
dens = Density
lv = GetDeviceLayoutValues
Log(dens)    [color=red] 1.5 [/color]
Log(lv.Height ) [color=red] 800 [/color]
Log(lv.Width ) [color=red] 480 [/color]
Log(lv.Scale ) [color=red] 1.5 [/color]

Therefore, I assumed the density was 240 (160x1.5)

My original layouts were designed with 320x480 using the default emulator. They displayed OK on a phone and perfectly on my Coby 7015a. I thought I had cut a fat hog until I asked others to verify what I was finding. nfordbscndrd was kind enough to check it for me a few weeks ago. He reported the layouts did not fit his Archos 70 but were acceptable. They were smaller and in the upper left corner. I found the same to be true when I borrowed a galaxy tab. Therefore I tried to design specifically for a 7" tablet using similar selections as shown in my earlier post, except I used a density of 160. That result worked fine on the archos and the galaxy but now did not fit my tablet. Many views were off the screen. It looked like everything needed to shift up and left. So that is where I left it with the hope that my 7" layout would work for most users that don't have my tablet. For those who do, I will send the original version. I thought Coby might have some answers but they are essentially unresponsive.

If any of you were designing only for a 7" tablet using the emulator, what would be your step by step procedure? I may have missed the mark with my method.

Thanks. Jim
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
Being somewhat of a Newbie to b4a, I don't know whether or not ths is appropriae. However, whenever I use Bridge, it shows the device parameters on the right under the New Variant button. My Evo shows up as "480 X 800 Scale 1.5" {I think it also says "(240)"). As I recall, if I turn the Evo into landscape, it changes to 800 X 480 -- but I could be wrong about ths.
 
Upvote 0

jschuchert

Active Member
Licensed User
Longtime User
Thank you. My tablet also shows 480x800 scale=1.5 (240 dpi) when connected via the bridge. I believe your device is supposed to have 240 dpi but not mine. Perhaps there is an internal quirk. I know I have spent a lot of time trying to figure it out.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Thank you. My tablet also shows 480x800 scale=1.5 (240 dpi) when connected via the bridge. I believe your device is supposed to have 240 dpi but not mine. Perhaps there is an internal quirk. I know I have spent a lot of time trying to figure it out.

mjtaryan has a 1.5 scale because he has 480x800 on a 4" phone. If you have a 7" tablet with 480x800 resolution, it must, mathematically, be a 1 scale (~160 dpi) tablet.

The math is shown at a link I've given you before:
Designer - Basic4android Wiki
 
Upvote 0

jschuchert

Active Member
Licensed User
Longtime User
Please don't misunderstand. I believe you and appreciate your help and refer often to the information in the links you have provided. I wish I knew the reason why "GetDeviceLayoutValues" shows 1.5 density. And I am baffled why my tablet is not consistent with others like yours and the galaxy tab in displaying my app. I can live with it, though, since I am confident that my 480x800 layouts designed on the actual size 7" emulator fit other tablets. I just can't see what they look like on mine.

If you were designing for a 7" tablet, would you just open the default emulator and use the 7" variants? On mine (21" monitor) the emulator image is quite large and almost fills the screen top to bottom. The 10" exceeds the limits of my screen so I have to go to 'actual size' to see the layouts. Is there a way to reduce the size?
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
If your 7" tablet is saying that it has a 1.5 density with 800x480 resolution, it has to be a bug in the tablet. Someone with an Archos 7 was reporting on here recently that his tablet returns incorrect specs, so it happens.

I have 21" and 23" monitors on my notebook and I use the 23" one for using the emulators. If I don't "scale display to real size", the emulators are larger, but nothing close to full screen. When I use scaling to 7" or 10", they are a little smaller than actual size, but that's what I always use so that I get a better idea of what button sizes and text sizes will be.

On my 23" monitor, the "monitor dpi" is 96. I think you said yours is about half that. Try increasing your monitor dpi.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Density is a logical dpi and does not have to directly relate to the physical display size at all. From Googling it does seem that the designers of the Coby 7015 chose to endow it with a logical density of 240dpi rather than the more normal 160dpi for a tablet of that size. It's not a bug, it's a rather silly design choice. Perhaps they just adopted an Android build from a 480 x 800 phone.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Density is a logical dpi and does not have to directly relate to the physical display size at all. From Googling it does seem that the designers of the Coby 7015 chose to endow it with a logical density of 240dpi rather than the more normal 160dpi for a tablet of that size. It's not a bug, it's a rather silly design choice. Perhaps they just adopted an Android build from a 480 x 800 phone.

Can I call it a "bug" if it's a silly design choice? ;) I was just thinking of the physical density (not logical density), but your theory that they did it to use an Android build from a phone makes sense. Also, I should have realized that physical density isn't that important since the physcial density of a 7" tablet with 800x480 resolution is actually around 133dpi, not 160dpi, so its just the logical density that matters. My bad.
 
Upvote 0

jschuchert

Active Member
Licensed User
Longtime User
Thank you for your clarifying discussion with agraham. Now I know why my tablet displays as it does and possibly why techs at Coby are not responding to my questions. They are hiding.

My monitor is set at the highest setting (96dpi) but looks like when setting up the emulator, it says 72 dpi and scale 0.54. That doesn't seem to have any affect so I won't worry about it. My monitor works with landscape for the non-actual size 10" emulator but not portrait (top is off the screen) so I will use the actual size for any emulator design. Thanks again for your help.

Jim
 
Upvote 0
Top