我是编写XML文件的初学者,它与C和C 不同。因此,任何人都可以告诉我如何在此文件中发表评论?
您可以使用html评论标签:
<!--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>
<!-- your comment here -->
这就像html评论
例如
<!--This is a comment-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">