  The internal distribution of heavy elements, in particular the radial
metallicity gradient, offers insight into the merging history of galaxies.
Using our cosmological, chemodynamical simulations that include both detailed
chemical enrichment and feedback from active galactic nuclei (AGN), we find
that stellar metallicity gradients in the most massive galaxies
($\sim3\times10^{10}$M$_\odot$) are made flatter by mergers and are unable to
regenerate due to the quenching of star formation by AGN feedback. The fitting
range is chosen on a galaxy-by-galaxy basis in order to mask satellite
galaxies. The evolutionary paths of the gradients can be summarised as follows;
i) creation of initial steep gradients by gas-rich assembly, ii) passive
evolution by star formation and/or stellar accretion at outskirts, iii) sudden
flattening by mergers. There is a significant scatter in gradients at a given
mass, which originates from the last path, and therefore from galaxy type. Some
variation remains at given galaxy mass and type because of the complexity of
merging events, and hence we find only a weak environmental dependence. Our
early-type galaxies (ETGs), defined from the star formation main sequence
rather than their morphology, are in excellent agreement with the observed
stellar metallicity gradients of ETGs in the SAURON and ATLAS3D surveys. We
find small positive [O/Fe] gradients of stars in our simulated galaxies,
although they are smaller with AGN feedback. Gas-phase metallicity and [O/Fe]
gradients also show variation, the origin of which is not as clear as for
stellar populations.
