2016-12-02 129 views

回答

1

<!-- your comment here -->

這就像HTML commentting

1

例如

<!--This is a comment--> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp"> 
1

您可以使用html comment tag這樣的:

<!--This is a comment. --> 

但請注意,如果你添加在類似的android xml標記中發表評論這樣的:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    <!--WARNING This is not a valid comment. --> 
/> 

Android Studio中的佈局編輯器會給你一個錯誤。您只能將其添加的XML之外標籤是這樣的:

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <!--This is a valid comment. --> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
     /> 
    </LinearLayout> 
相關問題