i have setting in app user can change theme. settings can reached via navigation drawer, , since want have "hamburger menu icon" i've had extend appcompatactivity base activity.
my styles.xml simple:
<style name="apptheme" parent="theme.appcompat.light.darkactionbar"> </style> <style name="darktheme" parent="theme.appcompat"> </style> and oncreate method:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); sharedpreferences = preferencemanager.getdefaultsharedpreferences(getbasecontext()); sharedpreferences.registeronsharedpreferencechangelistener(mainactivitytransmit.this); theme = sharedpreferences.getstring("theme_preference","1"); switch(theme) { case "apptheme": settheme(r.style.apptheme); break; case "darktheme": settheme(r.style.darktheme); break; default: break; } setcontentview(r.layout.activity_main_transmit); before, when extended activity (and used regular material themes) worked fine. however, when extend appcompatactivity (and use appcompat themes) doesn't work.
the text color changes depending on theme change to, background colors of both screen , actionbar stays same 1 in androidmanifest (darktheme in case).
why different because use appcompat , how fix it?
Comments
Post a Comment