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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM