futlib
futlib

Reputation: 8398

Android: Density independent pixels and the Samsung Galaxy Tab

I've done absolute positioning on Android via density independent pixels and it works great on all the available emulator profiles. However, the Samsung Galaxy Tab has a density of 240 (like WVGA devices), but a much larger resolution: 1024x600. As a result, the positioning is off.

Are there other devices where density and resolution don't seem to fit together? How should I tackle these issues? It basically means I can't use density independent pixels, doesn't it?

Upvotes: 1

Views: 1587

Answers (2)

Jonas Alves
Jonas Alves

Reputation: 1336

You shouldn't use absolute positions. You should use RelativeLayout.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007624

Are there other devices where density and resolution don't seem to fit together?

Density and resolution have no relationship whatsoever and never have. Hence, they either never or always "fit together", depending on how you wish to use that phrase.

How should I tackle these issues?

Considering that you did not really describe any "issues", that is impossible to answer.

It basically means I can't use density independent pixels, doesn't it?

Density-independent pixels are not supposed to work with absolute positioning, because absolute positioning is defined as "positioning based on hardware pixels". In general, absolute positioning is to be avoided wherever possible. Density-independent pixels, for their intended uses (e.g., whitespace between adjacent widgets via margins), are just fine.

Upvotes: 4

Related Questions