Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments in layout XML not working

Tags:

android

yes, I looked it up!

<!-- comment --> 

seems to be the right choice, but I get an error in android-studio Gradle: Error parsing XML: not well-formed (invalid token)

when I do this

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    <!-- android:background="?android:attr/selectableItemBackground" -->
    android:id="@+id/imageButton" 
    android:layout_alignParentTop="true"
    android:src="@drawable/gfx_select_medium"
    android:layout_marginRight="22dp"/>

any help is appreciated, thx!

like image 669
Michael D. Avatar asked Nov 02 '13 15:11

Michael D.


1 Answers

XML comments cannot be placed inside tag markup. Move the comment for example above or below your ImageButton tag.

Here's the spec reference, with emphasis added:

Comments may appear anywhere in a document outside other markup

Where markup is defined as:

Markup takes the form of start-tags, end-tags, empty-element tags, entity references, character references, comments, CDATA section delimiters, document type declarations, processing instructions, XML declarations, text declarations, and any white space that is at the top level of the document entity (that is, outside the document element and not inside any other markup)

like image 193
laalto Avatar answered Oct 22 '22 21:10

laalto