I was just wondering whether it is possible to have the Android Layout designer show a custom user created theme. When I select the theme it only shows all the android defaults. Does anyone have a way to achieve this?
You should be able to select project themes if you have a values/themes.xml or values/styles.xml file.
Ah! I found the problem!
It seems I was using a really bad naming convention in my themes.xml file.
I was declaring it like this:
<style name="App_Theme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen"> <!-- some items --> </style>
when I should have been doing it like this:
<style name="Theme.App_Theme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen"> <!-- some items --> </style>
I have a beginner's problem, hehehe
when I select this theme, my app in the phone have the default theme. What do I do wrong?
That just specifies the theme that the layout designer uses as a sort of preview. To apply the theme, you have to add it to your activity like this
[Activity(Label = "My Activity", Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen")]
public class TestActivity : Activity
Thank you for your help!
Can I change the Theme in runtime?
As far as i know, you can only change the theme when the activity is loaded.
So in the protected override void OnCreate(Bundle bundle) method, you can call SetTheme(Android.Resource.Style.ThemeLightNoTitleBarFullScreen); and that should work
protected override void OnCreate(Bundle bundle)
thank you for your help!
How do I specify a Theme for the entire Project?
Anyone have an idea on this? How do I set a project wide theme? Also, do I have to manually pick the theme I want to show in the layout editor every time or will the default theme load there when I can actually change it? Thanks! Kit
You set the application theme in AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" />
It is possible to make an axml layout a theme.
Or there is a way to hide or replace the initial black theme (default themes) in your application.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies