KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to calculate a variable amount of pixels to density independent pixels and vice-versa. This formula (px to dp): dp = (int)(px / (displayMetrics.densityDpi / 160)); does not work on small devices because it is divided by zero. This is my dp to px formula: px = (int)(dp * (displayMetrics.densityDpi / 160)); Could someone give me some pointers?
Tags (comma-separated)
Save Edits
Cancel