2013-07-23 42 views
-1

在Android項目工程的xml文件註釋格式通常是這樣的:在XML文件

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

<Button 
    android:id="@+id/btn_dialog" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Click to display a dialog" 
    android:onClick="onClick" /> 
</LinearLayout> 

是否有可能一個標籤中註釋掉只是一個或兩個參數?例如,我可以在上面的代碼中註釋掉android:layout_width或兩行android:layout_width and android:layout_height嗎?

回答

3

對不起,XML不允許您在標籤內嵌入註釋。

http://www.w3.org/TR/2008/REC-xml-20081126/#sec-comments

+0

如果我想在上面的示例代碼中只改變一行來檢查它的效果,還有其他簡單的方法來做到這一點,比如C的''//'嗎?是否可以使「

+0

最簡單的方法就是簡單地剪切線條,這樣您就可以測試並重新粘貼。您也可以在標籤下方發表評論,並臨時粘貼該屬性。 –

2

編輯:

對不起,註釋不能標記,例如內發生<tag ></tag>.

+0

我不認爲這是可能的 – user13267

+0

不,這是可能的,它的工作,你想? –

+0

請參閱http://stackoverflow.com/a/17800152/1693203 – user13267