After the World War 2, the British didn't have enough resources to continue their administration in a country as vast as India. They left by choice.
It does not mean that Gandhi didn't try, but the Britishers didn't bat an eye to his methodology. He was easily con vincible and Britishers used this to their aid. He has been constantly accused as one of the biggest hypocrite of Pre - Independence India.