Project theme in layout designer

Hey guys

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?

Posts

  • LluisSanchezLluisSanchez ESXamarin Team Xamurai

    You should be able to select project themes if you have a values/themes.xml or values/styles.xml file.

  • DustinMcDonaldDustinMcDonald USMember

    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>

  • MauricioSierraMauricioSierra USMember

    Hello,
    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?

    image

    thank you,

  • DustinMcDonaldDustinMcDonald USMember

    Hi @MauricioSierra

    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

  • MauricioSierraMauricioSierra USMember

    Hello @DustinMcDonald

    Thank you for your help!

    Can I change the Theme in runtime?

  • DustinMcDonaldDustinMcDonald USMember

    Hi @MauricioSierra

    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 :)

  • MauricioSierraMauricioSierra USMember

    Hello @DustinMcDonald

    thank you for your help!

  • How do I specify a Theme for the entire Project?

  • KitKerbelKitKerbel USMember

    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

  • ArthurKaterArthurKater TWMember ✭✭
    edited March 2014

    You set the application theme in AndroidManifest.xml

    example:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" />
        <application android:theme="@style/MyTheme"></application>
    </manifest>
    
  • carleslscarlesls ESMember

    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.
    Thank you.

Sign In or Register to comment.