注释在布局XML不工作 [英] Comments in layout XML not working

查看:103
本文介绍了注释在布局XML不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我看着它!

<!-- comment --> 

似乎是正确的选择, 但我得到的机器人工作室的错误 摇篮:错误解析XML:没有良好的(标记无效)

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

当我这样做

<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"/>

任何帮助是AP preciated,THX!

any help is appreciated, thx!

推荐答案

XML注释不能放在标记标记内。移动注释,例如高于或低于的ImageButton 标记。

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

如果标记的定义为:

标记需要起始标记,结束标记,空元素标签,实体引用,字符引用,评论的形式,CDATA段定界符,文档类型声明,处理指令,XML声明,文本声明,以及任何空白即在文件实体的顶层(即,文档元素外,而不是内部的任何其他标​​记)

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)

这篇关于注释在布局XML不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆