In-beam -ray spectroscopy using fragmentation reactions of both stable and radioactive beams has been performed in order to study the structure of excited states in neutron-rich oxygen isotopes with masses ranging from to 24. For the produced fragments, -ray energies, intensities, and coincidences have been measured. Based on this information new level schemes are proposed for up to the neutron separation energy. The nonobservation of any -decay branch from and suggests that their excited states lie above the neutron decay thresholds. From this, as well as from the level schemes proposed for and , the size of the and 16 shell gaps in oxygen isotopes is discussed in the light of shell-model calculations.