android - Android XML布局: Error parsing XML: not well-formed (invalid token) - I did close my View tags

标签 android xml compiler-errors parsexml

我在Button View 上收到此错误。从我在SO上看到的许多问题来看,当您没有正确关闭 View 时,似乎会出现此错误。

我认为我已经正确关闭了所有标签,但仍然收到此错误。这是为什么?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <Button 
        android:layout_width="wrap_content"
        android:layout:height="wrap_content"
        android:text="@string/mainActivity_button1"
        android:onClick="startSecondActivity" />

</RelativeLayout>

最佳答案

属性名称中有一个附加的/典型的:

更换

android:layout:height


android:layout_height

该错误不仅与未关闭的标签有关,而且还与XML语法问题有关。在XML中,一个属性只能有一个 namespace 前缀,并且 namespace 前缀与名称之间用:分隔。

关于android - Android XML布局: Error parsing XML: not well-formed (invalid token) - I did close my View tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27017705/

相关文章:

c++ - boost::spirit -- 试图编译最简单代码的编译器错误

c - 通过虚拟机使用gcc编译时出现问题

android + 谷歌地图 API v2

android - 如何检测用户何时在其 Android 设备上按下 "menu"键?

android - 代码一次又一次地请求雅虎天气服务

javascript - 在变量中使用 .each() .find() 和 .text()

java - 如何使用java在xml文件中包含xsl样式表

android - "Top level element is not completed"是什么意思?

Android - 单击按钮滚动到 View 顶部

java - 在android中创建alertbox时出错