Scaling: Designer vs. Actual Device

rfhall50

Member
Licensed User
Longtime User
Background
I have an app that superimposes a red circle (small jpg file) on top of a larger graphic file (also jpg). The purposes is to show our emergency team the exact location of a resident. The idea is that the large graphic is set in place, then simply set the small graphic to the correct x,y coordinates. Mechanically, the process itself works great. I do the design using the actual device conntected via a usb cable - not with an emulator.

Problem
Using designer, I see a full size graphic, and the red circle is exactly where I place it. When I compile and install on the device (it's a Droid X2), the background is significantly smaller, and the red circle is smaller and not in the correct location.

Again the design and the execution are both done using the same device.

Can someone help me to understand why design and execution are different.
Thank You.
Bob
 

Kevin

Well-Known Member
Licensed User
Longtime User
I'm still learning the ropes on all of this stuff too, but one thing you can try is creating a new layout variant closer suited to your device. From what I understand, Android doesn't always scale correctly. Of course I could be completely wrong (didn't I mention I am a :sign0104: ?) but it's worth a try.

According to a Google search, the specs on the Droid X2 are:

960x540 @ 256 DPI

When your device is connected to the Designer, it should show what it thinks the specs are. I would try creating the new layout to match that or the specs above and see if it looks any better.


The only other thing I can think of is if you are changing the sizes and coordinates of the circle or graphic through code, then you would need to do so using "dip" (device-independent pixels) rather than literal pixels. Again I don't know much about this either, but it is something I have seen while browsing this forum.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Do the settings for Show Title and Full Screen in designer match the activity settings on the project menu?
 
Upvote 0

rfhall50

Member
Licensed User
Longtime User
Thank you for the replies. When I connect the Droid-X2, designer sees it as 320x480. I also tried setting it up as 640x560 - same results - compiled version has a much smaller display. Also checked the Full Screen and Compiler options - neither combination seems to affect the end result.

You mentioned different devices and scales, etc. Since I am developing, compiling, and testing using the same USB connectected device, scales should all be the same.

I do realize that when this proof-of-concept is working, I will need to consider other screen sizes.

Thank you .... Bob
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Thank you for the replies. When I connect the Droid-X2, designer sees it as 320x480. I also tried setting it up as 640x560 - same results - compiled version has a much smaller display. Also checked the Full Screen and Compiler options - neither combination seems to affect the end result.

You mentioned different devices and scales, etc. Since I am developing, compiling, and testing using the same USB connectected device, scales should all be the same.

The puzzling part is that Designer sees the 540x960 device as 320x480. I assume that you are looking in the bottom-right corner of Designer where it says "Device details" and not in the Layout Variants box where the default is 320x480?

If Designer really sees the device as 320x480, then it might explain why the app would look smaller when compiled and run on the 540x960 device.

You might want to take a look at this page in the Documentation Wiki. I don't think anything there is going to solve this problem, but it does have a lot of realted info.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
According to the Motorola specs the Droid X2 has a logical dpi of 240 and hence a scale of 1.5.

It may not be a Designer problem. It you are laying out a scale 1 layout then the Designer will put scale 1 co-ordinates in the layout but as the device is scale 1.5 it will multiply the actual x and y by the scaling factor for display. Similarly at runtime on the device Basic4android will choose a layout and then multiply the chosen layout co-ordinates by the device scale factor and divide them by the layout scale. There are no complications, that is simply how the scaling that is done.

It looks more likely you are sizing a bitmap or positioning your graphic at run time using absolute co-ordinates which are appropriate for the values that you might see in a scale 1 layout and overlooking that they need to be specified as dips to be correct on a scale 1.5 layout.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
According to the Motorola specs the Droid X2 has a logical dpi of 240 and hence a scale of 1.5.

In this case, not only does the X2 have a logical dpi of 240, but a physical dpi a little higher than that, so it is legitimately a 1.5 scale. What I don't understand is why "designer sees it as 320x480", as he says. I suspect he is looking at the default variant rather than far bottom-right corner where Designer shows the specs for the connected device.

It may not be a Designer problem. It you are laying out a scale 1 layout then the Designer will put scale 1 co-ordinates in the layout but as the device is scale 1.5 it will multiply the actual x and y by the scaling factor for display.

Well, I officially don't understand half what I thought I did about layout scaling.

I just created a layout with 3 buttons on a layout of 960x540x1.5 (the X2 dimensions). I created it on a 7" tablet with a resolution of 800x480x1. I put one button at 0,0, one in the middle of the layout, and one in the bottom right corner.

The funny thing is that the bottom-right button, which is 100x100, when tucked into the bottom right corner, has a left-top of 1040x540. If you add the 100x100 size of the virtual resolution of the screen is 1140x640, excluding the soft menu on the right and the Activity and system bars at the top.

Where the heck is that coming from? Anyway, when compiled and run, the buttons all appear on screen just where I put them with Designer.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Well, I officially don't understand half what I thought I did about layout scaling.
I didn't to begin with because I was expecting it to be far more complicated than it is.

Layout co-ordinates(top, left, width and height) have the scale of the layout associated with them.

Display (absolute) co-ordinates are calculated as layout_coord * device_scale / layout_scale.

That's all there is to scaling!

The funny thing is that ... has a left-top of 1040x540.
That looks about right. 1040 and 640 are scale 1.5 co-ordinates. The Designer (and runtime) using that layout will scale them as 1040*1.0/1.5 = 693 and 640*1.0/1.5= 427 on your scale 1 device which is lower right. The buttons size will be similarly scaled.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
That looks about right. 1040 and 640 are scale 1.5 co-ordinates. The Designer (and runtime) using that layout will scale them as 1040*1.0/1.5 = 693 and 640*1.0/1.5= 427 on your scale 1 device which is lower right. The buttons size will be similarly scaled.

Ahhh.:BangHead: I was looking at 800x480 x 1.5 being 1200x720 instead of working backwards from 1040x640 like you did.

I didn't to begin with because I was expecting it to be far more complicated than it is.

Layout co-ordinates(top, left, width and height) have the scale of the layout associated with them.

Display (absolute) co-ordinates are calculated as layout_coord * device_scale / layout_scale.

That's all there is to scaling!

I had a problem one time that I don't think is covered by the above. I created a layout on a 7" 800x480 tablet:
800x480x160_layout.jpg


Then I ran it on a 10" 1280x800 tablet and got this:
800x480x160_layout_on_1280x800x160.jpg


The ImageViews holding the card faces were not resized because both devices were scale 1, which made them too small for the 10" tablet. So I had to do a layout for larger scale 1 tablets in which I manually made all the views (and text) larger.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I had a problem one time that I don't think is covered by the above....The ImageViews holding the card faces were not resized
Eactly! You are, like me initially, expecting it to be more complicated than it really is. They aren't resized because the scale is the same in both cases.
 
Upvote 0
Top