Drawing text

gjoisa

Active Member
Licensed User
Longtime User
while drawing text in canvas , x position and y position should be expressed with word "dip" . what is this dip ? why should be this used ? Why should not we use only integer or float values(20,20,....):sign0085:
 

derez

Expert
Licensed User
Longtime User
It doesn't have to, you can use only integers, but the dip means automatic adjustment to the size of the display so it will accomodate to different types of devices.
 
Last edited:
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
use dips on emulator, code, everywhere?

I use the emulator using resolution 240x400, density 120 (WQVGA400)

my phisical device is samsng galaxyS, 480x800 (density??)

when I design views using the the emulator (so using absolute coords), everything is OK

... but when I define (example) the .left property of view by code... I become mad
If I don't use "dip", the effect is different between emulator and phisical device (different position)
If I use "dip", the screen size seems to be different, example if my screen is width=480, the .left= 240dip is not in the middle but on the right side

what is the correct way?
hoW to use dip having the emulator to behave like the code "using dips"?
I mean: coord 240,400 should be always the exact centre of the screen, on the emulator, using code and on the phisical device (device 240x400 OR 480x800)

thank you
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The galaxy S density is 240 (scale = 1.5).
1dip = 1 pixel if density = 160 (base density).

You can work with the standard size emulator which is 320x480 density 160 (scale = 1).
Or if you want the layout to fix your device exactly and still use scale=1 then create an emulator with screen size of 320x533 density 160.
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
emulator vs code

... so this way I will have the emulator behave like my real physical device.

during design on the emulator should I use "absolute" coords?
example
if I see that the center screen is 50,50
- on the emulator I say "draw button at 50,50"
- using code I say "move button to 50dip,50dip"? (and it will not move?) or "move button to 50,50"?

the emulator does not permit to use the "dip" parameter, so I get confused when I create views on the emulator and then I need to move them by code...

I don't want to write a program that will look correctly only on "that" device...

thank you again
 
Upvote 0
Top