Created
April 11, 2015 10:13
-
-
Save hangox/b409a40abb7e872a61d3 to your computer and use it in GitHub Desktop.
一个Android中dp2px代码
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
public static int dpToPx(Context context,float dpValue) { | |
final float scale =context.getResources().getDisplayMetrics().density; | |
return (int) (dpValue * scale + 0.5f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment