资产中缺少Xamarin Main.xml,然后布局包含格式错误的xml - 缺少Root元素

时间:2016-01-04 18:55:06

标签: android xml android-layout xamarin xamarin-studio

我开始使用Xamarin工作室,我已经构建了最基本的表单项目。在教程中,它展示了如何编辑Main.xml中的布局,该布局应该在我的解决方案中缺少的Resources/layout中。因此,当我手动添加它时,它会失败并显示错误消息The layout contains malformed XML和另一个Root element is missing。当我在记事本中打开Main.xml时,我可以看到内容为<?xml version="1.0" encoding="UTF-8" ?>

enter image description here

适当的空白Main.xml的内容应该是什么样的?

2 个答案:

答案 0 :(得分: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> />**

答案 1 :(得分:0)

自己想出来

点击来源,然后添加

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">

那应该这样做。

enter image description here