Many animals, including humans, can visually judge the absolute size of objects regardless of changes in viewing distance and thus despite the resulting dramatic differences in the size of the actual retinal images. For animals that have to judge the size of aerial objects from underwater views, this can be a formidable problem; our calculations show that considerable and strongly viewpoint-dependent corrections are needed to compensate for the effects of light refraction. Archer fish face these optical difficulties because they have to shoot down aerial insects over a wide range of horizontal and vertical distances. We show here that these fish can learn to acquire size constancy with remarkable precision and are thus fully capable of taking complex viewpoint dependency into account. Moreover, we demonstrate that archer fish solve the problem not by interpolating within a set of stored views and distances but by learning the laws that connect apparent size with the fish's relative position to the target. This enables the fish to readily judge the absolute sizes of objects from completely novel views.