Apply a theme to an activity in Android?

Willy picture Willy · Oct 1, 2013 · Viewed 114k times · Source

I know how to apply a theme to a whole application, but where would I go to apply a theme to just a single activity?

Answer

Paresh Mayani picture Paresh Mayani · Oct 1, 2013

You can apply a theme to any activity by including android:theme inside <activity> inside manifest file.

For example:

  1. <activity android:theme="@android:style/Theme.Dialog">
  2. <activity android:theme="@style/CustomTheme">

And if you want to set theme programatically then use setTheme() before calling setContentView() and super.onCreate() method inside onCreate() method.