在Xamarin中,是否可以在布局文件夹中包含来自子文件夹的布局?

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

Is it possible to include layouts from subfolders within the layout folder in Xamarin?

问题

我试图在以下代码中分配一个布局:

<include
  layout="@layout/subfolder/boxes1_8" <!--问题在这里-->
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:layout_columnWeight="1"
/>

位于一个存储在子文件夹中的XML文件内在Xamarin中,是否可以在布局文件夹中包含来自子文件夹的布局?

我收到一个"无效配置 '72' 错误。

如何在XML中引用来自布局文件夹内子文件夹的布局?是否可能?

我已经尝试了以下XML格式:

layout="@layout/subfolder/boxes1_8"
layout="@layout/subfolder.boxes1_8"
layout="@(layout/subfolder/boxes1_8)"
英文:

I'm trying to assign a layout within the following code

<include
  layout="@layout/subfolder/boxes1_8" <!--The problem is here-->
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:layout_columnWeight="1"
/>

located within an xml file stored in a sub folder在Xamarin中,是否可以在布局文件夹中包含来自子文件夹的布局?

I get an "invalid configuration '72' error.

How can I reference a layout from a subfolder within the layout folder with xml? Is it possible?

I've tried these formattings in xml.

layout="@layout/subfolder/boxes1_8"
layout="@layout/subfolder.boxes1_8"
layout="@(layout/subfolder/boxes1_8)"

答案1

得分: 0

正如Jason所指出的,这是一个功能请求:为Android布局文件创建子文件夹的可能性 #2741,目前尚未实现。你可以关注该讨论帖:https://github.com/xamarin/xamarin-android/issues/2741。

作为替代方法,由erikpowa提供了一个解决方法,你可以尝试编辑csproj文件以包含如下的布局:

<None Include="Resources\layout\subfolder\activity_main.axml" />

<AndroidResource Include="Resources\layout\subfolder\activity_main.axml" Link="Resources\layout\activity_main.axml" Visible="false" />
英文:

As Jason has pointed it out, this is a feature request:Make subfolders for android layout files possible #2741 that hasn't been implemented yet. You can follow up that thread: https://github.com/xamarin/xamarin-android/issues/2741.

As an alternative workaround provided by erikpowa, you can try to edit the csproj file to include the layout like below:

<None Include="Resources\layout\subfolder\activity_main.axml" />

<AndroidResource Include="Resources\layout\subfolder\activity_main.axml" Link="Resources\layout\activity_main.axml" Visible="false" />

huangapple
  • 本文由 发表于 2023年7月7日 00:29:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76630861.html
匿名

发表评论

匿名网友

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

确定