Created
          October 4, 2013 03:10 
        
      - 
      
- 
        Save emedinaa/6820407 to your computer and use it in GitHub Desktop. 
    Convert dp to Pixel and px to DP
  
        
  
    
      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(int dp) | |
| { | |
| return (int) (dp * Resources.getSystem().getDisplayMetrics().density); | |
| } | |
| public static int pxToDp(int px) | |
| { | |
| return (int) (px / Resources.getSystem().getDisplayMetrics().density); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment