【问题标题】:"Error parsing XML: junk after document element"“解析 XML 时出错:文档元素后出现垃圾”
【发布时间】:2015-04-04 13:21:03
【问题描述】:

我在尝试创建自定义按钮时收到此错误消息,我已经尝试了与我的问题类似的大部分答案,但仍无法使其正常工作。非常感谢任何帮助。另外,由于这是我第一次在这里发帖,如有任何不妥之处,请见谅。

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
 <Selector
          xmlns:android="http://schemas.android.com/apk/res/android">
           <item android:drawable="@drawable/touchlighter" android:state_pressed="true"/>
           <item android:drawable="@drawable/touch"/>
 </Selector>
</RelativeLayout>

【问题讨论】:

    标签: android


    【解决方案1】:

    您正在输入&lt;Selector ...,&lt;RelativeLayout&gt; 的属性应该放在哪里。

    我认为正确的 XML 应该是:

    <?xml version="1.0" encoding="UTF-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">
        <Selector>
           <item android:drawable="@drawable/touchlighter" android:state_pressed="true"/>
           <item android:drawable="@drawable/touch"/>
        </Selector>
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-24
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多