Android Device Display Metrics suggest change

Formula px to dp dp to px conversation

DP to Pixel:

private int dpToPx(int dp)
{
    return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}

Pixel to DP:

private int pxToDp(int px)
{
    return (int) (px / Resources.getSystem().getDisplayMetrics().density);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents