0

I am learning Android and want to be able to add line comments to my XML so I can remind myself what things are doing.

Is there an accepted practice for this, or is it possible in Android Studio? I recall reading that comments in XML are hard, so I wanted to know if that was also considered true here.

AJJ
  • 2,004
  • 4
  • 28
  • 42

6 Answers6

3

As mentioned above you can comment in XML just like this:

<!-- Comment -->

But in android studio you can very easily toggle comment just by selecting what you want to comment and then pressing:

CTRL + /

This not only for XML but also for your java code for example.

Allinone51
  • 624
  • 1
  • 7
  • 19
1

It is indeed possible. I'm not sure if there is an accepted practice, but you can accomplish leaving a comment like this

<!-- comment goes here -->
joebro
  • 581
  • 3
  • 11
1

Same as in all XML applications: Just use <!-- ... --> to comment.

Kerkhofsd
  • 269
  • 1
  • 9
0

Comments in XML aren't too tough. You have to do it like this:

For example

<!-- This is a comment -->

Please don't hesitate to ask for anymore help. The above should work in android studio.

sjgandhi2312
  • 155
  • 1
  • 2
  • 10
0

If you are using a Mac then command is command(button which looks like Windows start button ) + / If you are on Windows then it is Cntrl + /

Try and see if it works

VarunJoshi129
  • 4,802
  • 1
  • 12
  • 10
0

In Android Studio DOLPHIN version I have tried using the and the file does NOT like it. It produces errors when used. I don't know about XML files much, but this AndroidManifest.xml file does not like this. Any other tips that might work? This file is error free before the comment line is added.

picture of errors

user8642620
  • 73
  • 1
  • 6