android - Theme Issue with PreferenceActivity -
in app let user choose theme wants use (dark or light). themes defined in styles.xml followed:
<style name="but" parent="android:style/widget.holo.actionbutton"> </style> <style name="bar" parent="android:style/widget.holo.actionbar.solid"> </style> <style name="theme_flo" parent="android:theme.holo"> <item name="android:buttonstyle">@style/but</item> <item name="android:actionbarstyle">@style/bar</item> </style> <style name="theme_flo_light" parent="android:theme.holo.light.darkactionbar"> <item name="android:buttonstyle">@style/but</item> <item name="android:actionbarstyle">@style/bar</item> </style>
the dark theme applied everywhere correctly.
the light theme ok except text color of actionbar (it's black instead of white) , preferenceactivity, consists of main preferencescreen , inner preferencescreens. inner screens have correct theme (except actionbar text color). outer preferencescreen (main screen) has dark background dark text color. guess text color choosen correctly, background color not. setting background color in settings.xml via android:background has no effect. i've found several posts black screen in inner preferencescreens not way.
the themes applied in oncreate method this:
public class settingsapp extends preferenceactivity implements onsharedpreferencechangelistener, onpreferencechangelistener { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if(timemateactivity.theme.equals("0")) { settheme(r.style.theme_flo); }else{ settheme(r.style.theme_flo_light); } addpreferencesfromresource(r.layout.settings); actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true); ... } }
i have checked correct theme choosen.
target , min api version 17, if important.
can me here?
move settheme
before super.oncreate(savedinstancestate);
code looks this:
public class settingsapp extends preferenceactivity implements onsharedpreferencechangelistener, onpreferencechangelistener { public void oncreate(bundle savedinstancestate) { if (timemateactivity.theme.equals("0")) { settheme(r.style.theme_flo); } else { settheme(r.style.theme_flo_light); } super.oncreate(savedinstancestate); addpreferencesfromresource(r.layout.settings); actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true); ... } }
Comments
Post a Comment