when the image ratio is not the same...

vangogh

Active Member
Licensed User
Longtime User
I desing an activity using the emulator 480x800, density 240
On my pc, I scale down to screen size 4.5 to show the full screen on my pc (1240x800)

I define a label here: x=470, y=724

now, RUN!

on my device 480x800 density 240 the label is in the lower-right corner.
OK, I wanted it there. good job, designer! :cool:

on a device 600x800 density 240 the label is... I don't understand... about 60% from the left and 60% from the top... :confused:

I was thinking I had simply a black stripe on the right because there are 120 "unuseful" pixels = 600-480

(of course if i put it form code, saying label.left=470 label.top=724 it goes "near" the right border, and close to the bottom border)

The auto-resizing feature does silly things... :(

so the question is: can I completely DISABLE the auto resize feature?
I will use the designer using absolute coords...
OR how can I control it (for this example: "dear device, use all the screen you can. the image is 480x800? use it. don't mind about your 120 more beautiful pixel..."
OR what can I do?

thank you
 
Last edited:

vangogh

Active Member
Licensed User
Longtime User
I got 800x600 scale 1 density 160

the device manual was wrong

... but I would expect to see the label "where it sould be" if the "dip" function works

this way I will have problems also if the resolution is 480x800 but different density... ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I define a label here: x=470, y=724

Did you define the x and y values by code ?
If yes you should use dip (density independant pixels) coordinates, that way the auto-scale should work.
Label.Left = 470dip
Label.Top = 724dip

Best regards.
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
Did you define the x and y values by code ?
If yes you should use dip (density independant pixels) coordinates, that way the auto-scale should work.
Label.Left = 470dip
Label.Top = 724dip

Best regards.

Coords where defined in the designer, not in the code. Here is the trouble.

If I define absolute coords in the code, I get the right (expected) position


I still don't understand what is the advantage using dips
when I use dip, actually I don't know where the pixel will be exactly on the device... I only get that the "physical size", measured in real life centimeters, is the same on different devices
when I use absolute coords, I know where is the screen center

Using dips I don't get that the coords always correctly "adapt" on different devices... what coords are the screen center?

the designer uses absolute coords, so I am using absolute coords also in the code.
:sign0161:

thank you
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
ok here attached there is the complete project, and 2 images:

- a screenshot of my emulator. I use a 480x800 resolution scaled 4.5 (so I can view all on my desktop)

- a photo of the device, and what I get


enjoy! :cool:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'll explain what happens here.
We have two devices
- 480x800, scale = 1.5 (emulator)
- 600x800, scale = 1 (tablet)

The scale factor means that the emulator has more pixels per inch than the tablet.
The "physical" size of the emulator matches a device with 320x533, scale = 1.
The emulator physical size is smaller than the tablet physical size.
480x800, scale = 1.5 are the dimensions of most Android phones (like HTC Desire, Nexus, Samsung S...).
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
The emulator physical size is smaller than the tablet physical size.

it should resize...
-----------------
after many tests, I think that the designer is, in my own opinion, a good start, but it is not (in MY opinion) "the" drawing solution... :sign0137:
I think I will position the views by code...

thank you!
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
You should set the emulator resolution to tablet resolution (including scale). This will solve your issue.

for sure, but I am working on a multi-device application

I am trying to, at least, make a layout that is shown properly on any device, using the designer... and on my pc I cannot work on a 800x600 scale 1 resolution (too big for my landscape monitor): I use an emulator res 800x480, "scale display to real size - screen size=4.5".
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The "scale display to real size" option is not important with regards to how it will look in a real device.
The important scale value is here:
20110524_1.png


You should set it to 160 (scale = 1) if you want it to behave like your tablet.
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
knowing that the layout that I create on the the emulator should "autoscale"on the real device, what is your suggestion about the "most compatible" emulator resolution/density (emulator-scaled to be visible on a pc monitor)?
I used 800x480 density 240 that looks bad on a 800x480 or 800x600 density 160...
Is it better to work (on the emulator) with high resolution but low density, or what?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
my original question was:

can I disable the "autosize" that b4a uses when it load the layout?

because if I define a 480x800 layout, it looks different on a 480x800 density 240 device and on a 480x800 density 160 device. same resolution, different behaviour (but ONLY when the layout is loaded - after that, pixel 240x400 is always the screen center)

I can provide photography, if needed
 
Upvote 0
Top