Created
May 12, 2014 09:23
-
-
Save sunwicked/812cce49c38fb8c568d8 to your computer and use it in GitHub Desktop.
Converting dp units to pixel units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The gesture threshold expressed in dp | |
private static final float GESTURE_THRESHOLD_DP = 16.0f; | |
// Get the screen's density scale | |
final float scale = getResources().getDisplayMetrics().density; | |
// Convert the dps to pixels, based on density scale | |
mGestureThreshold = (int) (GESTURE_THRESHOLD_DP * scale + 0.5f); | |
// Use mGestureThreshold as a distance in pixels... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment