Skip to main content
5 of 6
added 197 characters in body
Avijit Karmakar
  • 9.5k
  • 6
  • 48
  • 61

Here for commenting we have to write like below:

<!-- Your comment here --> 

For Windows & Linux:

Shortcut for Commenting a single line:

Ctrl + /

Shortcut for Commenting multiple lines:

Ctrl + Shift + /

For Mac:

Shortcut for Commenting a single line:

cmnd + /

Shortcut for Commenting multiple lines:

cmnd + Shift + /

One thing you have to keep in mind that, you can't comment an attribute of an XML tag. For Example:

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" <!--android:text="Hello.."--> android:textStyle="bold" /> 

Here, TextView is a XML Tag and text is an attribute of that tag. You can't comment attributes of an XML Tag. You have to comment the full XML Tag. For Example:

<!--<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hello.." android:textStyle="bold" />--> 
Avijit Karmakar
  • 9.5k
  • 6
  • 48
  • 61