Example: Blue sends out Heliolisk Red sends out Pikachu Heliolisk uses Rain Dance Pikachu uses Agility Heliolisk uses Dig
If Heliolisk's ability was Dry Skin would he still gain HP even though he is underground?
Dry Skin works as long as your Pokemon is on the field, even in invulnerable state like during Fly, Dig etc.
Source Hope I helped!