It is narrated from Sayyiduna Abdullah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever performs his prayer beautifully where people can see him, and performs it poorly (without attention and its conditions) when he is alone, that is in reality a contempt which he is showing towards his Lord."
Abu Ya'la al-Mawsili (may Allah have mercy on him) also narrated it.
This hadith is hasan (good).
Hadith Referenceإتحاف الخيرة المهرة بزوائد المسانيد العشرة / كتاب العلم / 395