If you've ever tried to use a PreferenceScreen inside a PreferenceFragment which has a transparent background (or it's parent activity has transparent background), you should have noticed that, instead of replacing the fragment, PreferenceScreen adds the fragment which makes it overlap with the previous fragment (i.e top fragment's content is visible on top of the fragment just below it). So, here's a quick solution for this issue:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, | |
Preference preference) { | |
super.onPreferenceTreeClick(preferenceScreen, preference); | |
if (preference != null) { | |
if (preference instanceof PreferenceScreen) { | |
if (((PreferenceScreen) preference).getDialog() != null) { | |
((PreferenceScreen) preference) | |
.getDialog() | |
.getWindow() | |
.getDecorView() | |
.setBackgroundColor(Color.BLACK); | |
} | |
} | |
} | |
return false; | |
} |