Advertisement
Guest User

Dip to Pix

a guest
Jul 17th, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. package com.blundell.tut.util;
  2.  
  3. import android.content.Context;
  4.  
  5. public class AndroidUtils {
  6.  
  7.     /**
  8.      * Converts the number in dips to the number in pixels
  9.      */
  10.     public static int convertToPix(Context context, int sizeInDips){
  11.         float scale = context.getResources().getDisplayMetrics().density;
  12.         float size = sizeInDips * scale;
  13.         return (int) size;
  14.     }
  15.    
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement