PreferenceActivity and theme not applying

后端 未结 5 1537
不思量自难忘°
不思量自难忘° 2020-12-14 16:25

Hi all I have set the theme in the manifest file like this:

android:theme=\"@android:style/Theme.Light\"

But I have a problem in the Prefer

5条回答
  •  再見小時候
    2020-12-14 17:23

    You can also use this technique to override the styles of the inner preference screens :

    @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()
                            .setBackgroundDrawable(
                                    this
                                    .getWindow()
                                    .getDecorView()
                                    .getBackground()
                                    .getConstantState()
                                    .newDrawable()
                            );
                }
            }
        }
        return false;
    }
    

    This code applies the style of the main preference screen to the clicked preference screen.

提交回复
热议问题