Search code examples
xamarin.androidmaterial-designandroidx

Matieral Design Shape Theming with Xamarin.Android


I'm trying to follow this documentation on shape theming and I'm hitting a wall.

here is my styles.xml file:

<resources>
    <style name="AppTheme" parent="Theme.MaterialComponents.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary</item>
        <item name="android:colorAccent">@color/blue</item>
        <item name="android:colorControlNormal">@color/very_light_gray</item>
        <item name="android:colorControlActivated">@color/light_gray</item>
        <item name="android:colorButtonNormal">@color/button_background</item>
        <item name="android:textColorSecondary">@color/gray</item>
        <item name="android:textColorPrimary">@color/primary_text</item>
        <item name="android:navigationBarColor">@color/primary</item>

        <item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.SmallComponent</item>
        <item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.MediumComponent</item>
        <item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.LargeComponent</item>
    </style>

    <style name="ShapeAppearance.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
        <item name="cornerFamily">cut</item>
        <item name="cornerSize">4dp</item>
    </style>

    <style name="ShapeAppearance.MediumComponent" parent="ShapeAppearance.MaterialComponents.MediumComponent">
        <item name="cornerFamily">cut</item>
        <item name="cornerSize">8dp</item>
    </style>

    <style name="ShapeAppearance.LargeComponent" parent="ShapeAppearance.MaterialComponents.LargeComponent">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSize">4dp</item>
    </style>
</resources>

When I go and build my app I get a list of errors:

figure-1

Here's the packages I have installed:

figure-2

I'm not sure if I'm missing a package or if Xamarin.Android has yet to support this. I know there are other ways to do this but I'd prefer to do it this way if I can.


Solution

  • Try to update Xamarin.Google.Android.Material nuget to the latest version,and install Xamarin.AndroidX.Legacy.Support.Core.UI nuget,it works for me.