Android Layout xml의 주석
레이아웃 XML 파일에 코멘트를 입력하고 싶은데 어떻게 하면 될까요?
다른 사람이 말했듯이 XML에 있는 댓글은 이렇습니다.
<!-- this is a comment -->
여러 선에 걸쳐 있을 수 있음을 주목하십시오.
<!--
This is a comment
on multiple lines
-->
그러나 중첩할 수 없습니다.
<!-- This <!-- is a comment --> This is not -->
또한 태그에 사용할 수 없습니다.
<EditText <!--This is not valid--> android:layout_width="fill_parent" />
월드 와이드 웹 컨소시엄(W3C)은 실제로 코멘트 인터페이스를 정의했습니다.정의에 따르면 다음과 같이 말합니다.all the characters between the starting ' <!--' and ending '-->' form a part of comment content and no lexical check is done on the content of a comment
.
자세한 내용은 developer.android.com 사이트에서 확인할 수 있습니다.
시작 태그와 종료 태그 사이에 코멘트를 넣기만 하면 됩니다.에 Eclipse IDE를 입력합니다.<!--
댓글을 자동으로 작성해 드립니다.그런 다음 코멘트 텍스트를 중간에 추가할 수 있습니다.
예를 들어,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".TicTacToe" >
<!-- This is a comment -->
</LinearLayout>
은 in between
태그 안에서 사용할 수 없기 때문입니다.
예를 들어,
<TextView
android:text="@string/game_title"
<!-- This is a comment -->
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
잘못된 것이며 다음 오류를 줄 것입니다.
Element type "TextView" must be followed by either attribute specifications, ">" or "/>".
합니다.<!--
끝으로 마칩니다.-->
.
예를 들어,
<!-- This is a comment. -->
당신이 그렇게 할 수 있는 두 가지 방법이 있습니다.
로 합니다.
"<!--"
면"를 마칩니다.-->"
<!-- my comment goes here -->
코멘트 할 부분을 강조 표시하고 CTRL + SHIFT + / 를 누릅니다.
ctrl+shift+/ 코드를 댓글로 달 수 있습니다.
<!--
<View
android:layout_marginTop="@dimen/d10dp"
android:id="@+id/view1"
android:layout_below="@+id/tv_change_password"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#c0c0c0"/>-->
<!-- comment here -->
코멘트가 가능한 태그 INSIDE
주석/문서작성 목적으로 사용할 수 있는 사용자 지정 속성을 생성할 수 있습니다.
에서 a.documentation:info
속성은 다음과 같이 정의됩니다. 예를 들어 주석 값을 사용합니다.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:documentation="documentation.mycompany.com"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relLayoutID"
documentation:info="This is an example comment" >
<TextView
documentation:purpose="Instructions label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here to begin."
android:id="@+id/tvMyLabel"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
documentation:info="Another example comment"
documentation:translation_notes="This control should use the fewest characters possible, as space is limited"
/>
</RelativeLayout>
documentation.mycompany.com
는 정 XML 지정 입니다.documentation
), 따라서 고유 URI 문자열일 뿐입니다. 고유하기만 하면 무엇이든 가능합니다.documentation
xmlns:
또한 무엇이든 될 수 있습니다 - 이것은 다음과 같은 방식으로 작동합니다.android:
XML 네임스페이스가 정의되어 사용됩니다.
와 수 .documentation:info
,documentation:translation_notes
설명 값과 함께 형식은 XML 속성과 동일합니다.
요약하면:
- 를 합니다.
xmls:my_new_namespace
XML 레이아웃 파일의 루트(상위 수준) XML 요소에 속성을 지정합니다. 값을 - 시 XML 합니다)를 합니다.
<TextView my_new_namespace:my_new_doc_property="description" />
클릭.
창에서 ctrl+shift+/
Mac에서 명령 + control +/
당신과 모든 것이 댓글에 달게 될 것들이 댓글로 남겨질 것입니다.
댓글을 달려면Android Studio
간단히 누름:
+ /Ctrl 윈도//리눅스에서
+ /Cmd 맥에서/
이것은 다음과 같은 XML 파일에서 작동합니다.strings.xml
코드 파일 뿐만 아니라 다음과 같은 코드 파일에서도.MainActivity.java
.
한 줄에 대해 Ctrl+shift+/ 및 shift+/를 눌러 코멘트를 추가할 수도 있습니다.
페데리코 컬로카의 메모에서:
또한 태그에 사용할 수 없습니다.
즉, 파일의 맨 위 또는 맨 아래에 주석을 넣어야 합니다. 주석을 추가하려는 모든 위치가 최소한 맨 위 레이아웃 태그 안에 있습니다.
놀랍게도 2019년 안드로이드 스튜디오 3.3(정확한 버전은 모릅니다, 적어도 3.3)에서는 xml에 더블 슬래시 코멘트를 사용할 수 있습니다.
그러나 xml에서 double slash comment를 사용하면 IDE에 경고가 표시됩니다.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
// this works
/* this works too */
/*
multi line comment
multi line comment
*/
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World! yeah"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
언급URL : https://stackoverflow.com/questions/3484643/comments-in-android-layout-xml
'sourcetip' 카테고리의 다른 글
jQuery에서 '정의되지 않은' 값을 확인하는 방법 (0) | 2023.10.15 |
---|---|
클래스 이름이 특정 문자열로 시작하는 모든 요소와 일치 (0) | 2023.10.15 |
mysql 데이터베이스에 배열 저장 (0) | 2023.10.15 |
jQuery의 요소 또는 클래스 LIKE 선택기? (0) | 2023.10.15 |
요소의 한쪽에만 드롭 섀도우를 만드는 방법은? (0) | 2023.10.15 |