We investigate medium effects caused by density-dependent magnetic moments of baryons on neutron stars under strong magnetic fields. If we allow the variation of anomalous magnetic moments (AMMs) of baryons in dense matter under strong magnetic fields, AMMs of nucleons are enhanced to be larger than those of hyperons. The enhancement naturally causes the chemical potentials of the baryons to be large and leads to the increase of the proton fraction. Consequently, it causes the suppression of hyperons, resulting in stiffness of the equation of state. Under the presumed strong magnetic fields, we evaluate the relevant particle populations, the equation of state, and the maximum masses of neutron stars by including density-dependent AMMs and c...