Xamarin Android Error when switcing between light and dark theme

Seth Isaacks 11 Reputation points
2022-03-02T16:26:40.113+00:00

I have an Xamarin Shell Application. I recently added in AppThemeBinding so that when the user switches between Light/Dark on the phone settings the app will respond with the appropriate color changes. It works fine until I try to navigate tabs after switching from Light to Dark or Dark to Light. Then I get an error that is not very helpfull.

Android.Views.InflateException: 'Binary XML file line #1 in com.companyname.MobileApp:layout/rootlayout: Binary XML file line #1 in com.companyname.MobileApp:layout/rootlayout: Error inflating class <unknown>'

I have googled and googled but cannot find anything specifically dealing with this <unknown> error.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Seth Isaacks 11 Reputation points
    2022-03-03T02:45:49.72+00:00

    I figured out the issue, I had watched a video from one of the xamarin guys and they said to add a ConfigChanges.UIMode property in the MainActivity.cs. I must have missunderstood, but I thought they said it was required for Android to use AppThemeBinding but its not.

    1 person found this answer helpful.