【问题标题】:Xamarin Main.xml is missing from assets then Layout contains malformed xml - Root element is missing资产中缺少 Xamarin Main.xml,然后布局包含格式错误的 xml - 缺少根元素
【发布时间】:2016-01-04 18:55:05
【问题描述】:
我从 Xamarin 工作室开始,我已经构建了最基本的表单项目。在教程中,它展示了如何在Main.xml 中编辑布局,这应该在我的解决方案中缺少的Resources/layout 中。因此,当我手动添加它时,它会失败并显示错误消息 The layout contains malformed XML 和另一条 Root element is missing。当我在记事本中打开Main.xml 时,我可以看到内容为<?xml version="1.0" encoding="UTF-8" ?>。
正确的空白 Main.xml 的内容应该是什么样的?
【问题讨论】:
标签:
android
xml
android-layout
xamarin
xamarin-studio
【解决方案1】:
检查标记是否正确启动和关闭;例如,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="@drawable/fondomizzou" **/>**
NOT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="@drawable/fondomizzou"
**</RelativeLayout> />**
【解决方案2】:
自己想出来的
点击源,然后添加
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
应该这样做。