Back to project page spiderreddit.
The source code is released under:
MIT License
If you think the Android project spiderreddit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.davepayne.blogcrawler.util; /*w ww. java 2 s . com*/ import android.content.res.Resources; /** * Helper utility with lightweight methods for pixel to density-pixel (px to dp, respectively) * conversion and vice vera. */ public class GfxUtil { /** * * @param dp input density pixels. * @return returns conversion in pixels. */ public static int dpToPx(int dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } /** * * @param px input pixels. * @return returns conversion in density pixels. */ public static int pxToDp(int px) { return (int) (px / Resources.getSystem().getDisplayMetrics().density); } }