Back to project page CustomFilePicker.
The source code is released under:
GNU General Public License
If you think the Android project CustomFilePicker 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 my.app.browser.utility; /*ww w. ja va2 s .c o m*/ import android.content.Context; import android.util.DisplayMetrics; /** * Created by Rajiv on 8/9/13. */ public class DpiConvertor { public static int dpToPx(int dp, Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return px; } public static int pxToDp(int px, Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return dp; } }