Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Let the user choose a theme [Android]

Tags:

android

themes

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 "Light theme" or the "Dark Theme".

So basically I need help with the following:

  • Are there any built in themes in Android that I can use?
  • How do I get access to the themes?
  • Any other useful information. I'm really new at this.
like image 687
Tito Rahman Avatar asked Jun 15 '11 02:06

Tito Rahman


People also ask

How do I change the theme code in Android Studio?

In Android Studio, open themes. xml (app > res > values > themes > themes.

How do I stop my theme from changing on Android?

Turn Dark theme on or off in your phone's settings On your phone, open the Settings app. Tap Display. Turn Dark theme on or off.

Can we install custom themes on Android smartphones?

Related. Rooted Android phones have access to custom themes that replace your home screen, notification and other system graphics. Themes need to be compatible with the specific Android-rooted ROM you currently have on the phone.


1 Answers

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

like image 112
Joe Avatar answered Oct 24 '22 11:10

Joe