[mono-android] set theme/style programmatically
Jonathan Pryor
jonp at xamarin.com
Thu Jan 5 11:01:24 EST 2012
On Jan 5, 2012, at 10:46 AM, Tomasz Cielecki wrote:
> Yes, in your activity where you set Label and other parameters for it, you can set the theme.
...
> [Activity(Theme = "@style/Theme.MyAwesomeTheme", Label = "@string/MyAwesomeActivity")]
That's not programmatically, that's declaratively, as that winds up in AndroidManifest.xml setting the //activity/android:theme attribute. :-)
To programmatically set the theme, use Context.SetTheme(int):
http://androidapi.xamarin.com/index.aspx?link=M%3aAndroid.Content.Context.SetTheme(System.Int32)
http://stackoverflow.com/questions/4967904/androidhow-to-programmatically-set-an-activitys-theme-to-theme-dialog
It also sounds like SetTheme() needs to be invoked before calling base.OnCreate().
- Jon
More information about the Monodroid
mailing list