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