Padding and margin in DialogPreference

I implemented a Time Picker in the preference using the code found here where the class TimePreference extends the class DialogPreference but I found a lack of alignment with the other preference items because of a different setting of the margins and/or padding.

Preference element in xml and the click event

If you have an EditTextPreference tag in a xml file you can catch the click event implementing OnSharedPreferenceChangeListener but it doesn’t work if you have a Preference tag in the xml file.

Consider the following code inside a xml file for the preferences: