英文:
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"
/>
我收到一个"无效配置 '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
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" />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论