Android DP, SP to PX

private int dp2px(int value){
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,value,getResources()
                .getDisplayMetrics());
    }

    private int sp2px(int value){
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,value,getResources()
                .getDisplayMetrics());
    }

original text

Read More: