not gaining exp

i caught a ralts it only knows growl as it is lvl 5 and pokemon do not seem to gain exp unless they do damage. i tried using poison and swithching so it was the pokemon alive when fainting the opposition and this rewarded no pokemons any exp.