jersam515
jersam515

Reputation: 657

Why are my eclipse dp dimensions for the android graphical layout editor not accurate?

While trying to make a layout for my app, I noticed that while using the QVGA skin(240 by 320) I noticed a button 240dp by 160 dp does not fill half of the screen vertically, nor the entire screen horizontally. Any help would be greatly appreciated.

Upvotes: 0

Views: 429

Answers (1)

user658042
user658042

Reputation:

You seem to think that 1dp equals 1px, which is not (always) correct.

It depends on the screen density (thats how many pixels are displayed per inch) how many pixels equal 1dp. The 1 to 1 conversion only applies at 160 dpi (mdpi in android terms). If you have a QVGA display created in the emulator/eclipse, chances are that it's density is 120 aka ldpi (by default), so you get other dimensions. 1dp is smaller than 1px in this case, resulting in a smaller view.

See the dp description in the docs for more information.

Upvotes: 3

Related Questions