Search code examples
androidvisual-studioxamarinxamarin.androidvisual-studio-2022

Xamarin Android using Android studio for resources/layouts in vs 2022 / Electric eel?


I am recently back on an older Xamarin Android native project and VS has updated a few years/times since I last touched it. I was using Xameridea which created a parallel project to allow Android studio to be used for all layouts. I see VS2022 has updated their AXML editor but it is pretty poor compared to Android Studio. Xameridea is no more, as of 2019. This link talks about a way to do it via sourcesets:

However, most layouts are broken with errors regarding namespaces and lots of ANdroid studio level issues. So, I am wondering, how are you all maintaining your Xamarin android in vs 2022 in 2023?


Solution

  • I'm not sure what your problem is, but there is no problem using Android Studio Electric Eel and previous versions of AS to design your xml layouts for use in VS 2022. I've been using AS for my layouts for at least the last 3 or 4 years for both Xamarin.Android and now net7-android. As far as I'm aware, the Xamarin.Android designer hasn't been updated in that time period and is pretty much useless. All you need to do is create your layout in AS and then create a new layout in VS with the same name, and copy/paste the layout from AS overwriting whatever is in the Xamarin.Android designer, save it, build it and you are done.

    As for maintenance, it does mean you have an AS project that mimics your VS project as far as layouts. I'd suggest, unless you have something better, using something like Beyond Compare to be able to open both XML layouts at the same time and that when editing a layout you always push changes from the AS project to the VS project, not vice versa. You get the added benefit of using a superb layout editor using AS along with their Layout Validation tool. I really can't imagine how anyone would be able to build a complex ConstraintLayout using VS 2022's designer.

    VS has handled xml as compared to axml files for years now. I also don't understand your problem re namespaces - could you explain further with an example?

    I can point you to shared examples where all the layouts were designed in AS if you need to see examples.

    I just looked at the link you shared, and that suggestion also looks viable. Since it is an old link it may need to be modified to suit Electric Eel.