我在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/