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

huangapple go评论64阅读模式
英文:

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

问题

最近回到一个较旧的 Xamarin Android 原生项目上,VS 已经更新了几年/几次,自从我上次接触它以来。我之前使用的是 Xameridea,它创建了一个并行项目,允许使用 Android Studio 进行所有布局设计。我看到 VS2022 更新了他们的 AXML 编辑器,但与 Android Studio 相比,它相对较差。Xameridea 从2019年起不再更新。这个链接 提到了一种通过 sourcesets 实现的方法:

然而,大多数布局都存在命名空间错误和许多 Android Studio 层面的问题。所以,我想知道,你们在2023年是如何在 VS 2022 中维护 Xamarin Android 项目的呢?

英文:

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?

答案1

得分: 1

我不确定你的问题是什么,但使用Android Studio Electric Eel和AS的早期版本设计XML布局以在VS 2022中使用是没有问题的。我至少在过去3到4年里一直在使用AS来设计我的布局,用于Xamarin.Android和现在的net7-android。据我所知,Xamarin.Android的设计工具在这段时间内并没有更新,几乎没什么用。你只需要在AS中创建你的布局,然后在VS中创建一个同名的新布局,将AS中的布局复制粘贴覆盖Xamarin.Android设计工具中的内容,保存,构建,就完成了。

至于维护,这意味着你有一个与VS项目中的布局相仿的AS项目。我建议,除非你有更好的方法,可以使用诸如Beyond Compare之类的工具,能够同时打开两个XML布局,并且在编辑布局时,始终将AS项目中的更改推送到VS项目,而不是相反。这样做的额外好处是使用AS的出色布局编辑器以及他们的布局验证工具。我真的无法想象有人如何能够使用VS 2022的设计工具来构建复杂的ConstraintLayout。

多年来,VS一直处理XML而不是axml文件。我也不明白你所提到的关于命名空间的问题 - 你能举个例子进行进一步解释吗?

如果你需要看示例,我可以为你指出一些共享示例,其中所有布局都是在AS中设计的。

我刚刚看了你分享的链接,那个建议看起来也是可行的。因为它是一个旧链接,可能需要修改以适应Electric Eel。

英文:

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.

huangapple
  • 本文由 发表于 2023年2月19日 22:51:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定