Let the user choose a theme [Android]

前端 未结 1 1907
有刺的猬
有刺的猬 2021-02-04 19:59

I\'m have an app i\'m working on in which I\'m trying to let the user change the \"theme\" or the look of the layouts. Like how some apps have the option where you can pick the

相关标签:
1条回答
  • 2021-02-04 20:34

    You would need to create your themes using the standard Android theme/style process, and build a list of the Themes/resources you want to make available to the user (e.g., "Light" => R.style.MyLightTheme, "Dark" => R.style.MyDarkTheme, "iPhone" => R.style.iOSTheme). Expose that list of available themes to the user as, for example, a ListPreference in a Preferences/Settings screen.

    In your Activity's onCreate() method(s), before calling setContentView(), set the theme using this.setTheme(customTheme);

    customTheme would come from the shared preferences as mentioned above

    0 讨论(0)
提交回复
热议问题