android的布局xml文件如何添加注释?

xml布局文件如图添加注释后报错,错误内容如下:

上网查阅xml添加注释的语法规则:

XML 中的注释

在 XML 中编写注释的语法与 HTML 的语法很相似:

<!--This is a comment-->

并不是注释本身的问题。

因此可能是Android中的xml有特殊的规定,继续搜索发现有网友说:

Android中的xml只能在组件布局代码后,或者在组件的前面添加注释。如下所示:
<RelativeLayout
        android:id="@+id/item_layout"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <!--  -->
        <LinearLayout
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical" >
                  <!--  -->
        </LinearLayout>
</RelativeLayout>

果然这样之后就没有问题了。。。OTZ
原文地址:https://www.cnblogs.com/yanpanjiao/p/4596310.html