How to change PreferenceActivity theme?

前端 未结 5 957
执念已碎
执念已碎 2020-12-18 21:45

I\'m trying to change the theme for the PreferenceActivity in my app and I just can\'t get it to work.

This is the xml:

    

        
5条回答
  •  囚心锁ツ
    2020-12-18 22:43

    Have you tried applying the theme on the activity tag in the manifest? This is how I have done it before -

    
    

    EDIT:

    The other option you could try is to override onApplyThemeResource(Resources.Theme theme, int resid, boolean first). Looking at the android source code the setTheme will internally call method.

    /**
     * Called by {@link #setTheme} and {@link #getTheme} to apply a theme
     * resource to the current Theme object.  Can override to change the
     * default (simple) behavior.  This method will not be called in multiple
     * threads simultaneously.
     *
     * @param theme The Theme object being modified.
     * @param resid The theme style resource being applied to theme.
     * @param first Set to true if this is the first time a style is being
     *              applied to theme.
     */
    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
        theme.applyStyle(resid, true);
    }
    

提交回复
热议问题