Theme.MaterialComponents.Light.NoActionBar Causes Visual Studio 2022 to Ignore My Styles in Designer

Nathan Sokalski 4,106 Reputation points
2024-09-30T17:53:56.1433333+00:00

I am attempting to add a com.google.android.material.slider.Slider to my Xamarin.Android app. This forced me to change my AppTheme is styles.xml to Theme.MaterialComponents.Light.NoActionBar instead of Theme.Design.NoActionBar. Doing this caused the Designer in Visual Studio 2022 to ignore some (but not all) attributes of my custom styles. Everything still looks correct when running the app, but it makes certain things hard to design. Why is the MaterialComponents theme causing the Visual Studio 2022 Designer to disrespect my style(s)? Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,348 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,841 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,916 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Graham McKechnie 411 Reputation points
    2024-09-30T21:55:24.03+00:00

    I wouldn't advise relying on the Designer in Visual Studio 2022. The designer hasn't been worked on in years. It's a waste of time to even attempt to use it.

    Install Android Studio and then do all your xml work with that. Then Copy and Paste back to the xml file in VS2022. Or even better, use Beyond Compare to open both files simultaneously and push the Android xml to the VS2022 xml.

    You should also be using Theme.Material3.Light.NoActionBar, not Theme.MaterialComponents. etc as that is now out of date.

    If you want to see how theming is done for, say, Android 10-14. Take a look at my examples at https://github.com/gmck.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.