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