按钮错误的选择器“有效的XML文档必须具有根标签”。 [英] Selector for button error "Valid XML document must have a root tag"
本文介绍了按钮错误的选择器“有效的XML文档必须具有根标签”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有3张图像用于按钮
,使用png格式。
I have three image for Button
, using png format.
我制作了选择器
,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- pressed -->
<item android:state_pressed="true" android:drawable="@drawable/press_pdgmap" />
<!-- hover -->
<item android:state_focused="true" android:drawable="@drawable/hover_pdgmap2" />
<!-- default -->
<item android:drawable="@drawable/hover_pdgmap" />
</selector>
但是红色标记出现在按下行,悬停和默认行中,它表示
But red tag appear in line pressed, hover, and default, it says
顶级元素未完成,有效的XML文档必须具有根标记
Top level element is not completed, Valid XML document must have a root tag
注意:我正在使用Android Studio
note: I'm using Android Studio
推荐答案
顶级元素应为 selector
和XML文件应放在res / drawable /目录中。
示例:
Top level element should be selector
and XML file should be placed in the res/drawable/ directory.
Example:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/button_focused"
android:state_focused="true" />
<item android:drawable="@drawable/button_default" />
</selector>
这篇关于按钮错误的选择器“有效的XML文档必须具有根标签”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文