How to get Holo Light theme working in my Xamarin application

14,427

Solution 1

The breakdown is on this line.

<application android:label="FutureState App Demo" android:icon="@drawable/Icon" Theme="@style/FsmTheme" />

Some of the tutorials out there show

Theme="@style/ThemeName"

but you should actually structure it the same as the rest of the element

android:theme="@style/ThemeName"

So the final structure will read

<application android:label="FutureState App Demo" android:icon="@drawable/Icon" android:theme="@style/FsmTheme" />

Solution 2

You can use Attributes to modify values in the AndroidManifest.xml, for example this changes the theme to holo light:

[Activity(
    Label = "Foobar",
    MainLauncher = true,
    Theme = "@android:style/Theme.Holo.Light"
)]
public class MainActivity : Activity { ... }

You can also do this at the Application level.

But for your specific problem, it seems that you are naming your style files FsmTheme.xml. That is incorrect. You must name any styling resources styles.xml, so if you rename your files to Resources/values/styles.xml and Resources/values-v11/styles.xml everything should work as expected.

Share:
14,427

Related videos on Youtube

Chase Florell
Author by

Chase Florell

I'm a developer in BC Canada and one of the owners of Flo Media Group Inc. I work primarily in C# .NET, Xamarin, HTML5 and Javascript, and I'm also very passionate about DevOps, and have been known to sling my fair share of PowerShell. When I'm not coding, I'm enjoying time with my wonderful wife and children, riding my motorcycle, camping in the summer months, snowboarding in the winter, or maybe just a round at the Golf Course. I Blog Here, and I'm also on Linkedin Contact Me

Updated on September 15, 2022

Comments

  • Chase Florell
    Chase Florell almost 2 years

    I'm trying to get my app to use the Holo.Light theme. I've created a custom theme for Holo and put it in

    Resourses\values-v11\FsmTheme.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
        <style name="FsmTheme" parent="@android:style/Theme.Holo.Light">
        </style>
    </resources>
    

    I've also created one for older versions and put it in

    Resourses\values\FsmTheme.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
        <style name="FsmTheme" parent="@android:style/Theme.Light.NoTitleBar">
        </style>
    </resources>
    

    Then I added it to my AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="001" android:versionName="001" package="futurestate.app.droid">
        <uses-sdk android:minSdkVersion="12" android:targetSdkVersion="14" />
        <application android:label="FutureState App Demo" android:icon="@drawable/Icon" Theme="@style/FsmTheme" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.INTERNET" />
    </manifest>
    

    I'm not sure what else I would need to do to get the theme to take in the app.

    enter image description here

  • csvan
    csvan over 9 years
    This ought to be the accepted answer, as it really is the "Xamarin way" of solving the problem.