Guest User

Untitled

a guest
Jan 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. public static int dpToPx(float dp, Context context) {
  2. return dpToPx(dp, context.getResources());
  3. }
  4.  
  5. public static int dpToPx(float dp, Resources resources) {
  6. float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
  7. return (int) px;
  8. }
Add Comment
Please, Sign In to add comment