如何解决与其他可以正常运行的XML代码相同时,为什么我的XML代码崩溃?
| 我正在从书中构建我的第一个Android程序。它一直崩溃在XML文件上。我从书中下载了xml代码,并用它运行良好! 当我看着它们时,它们对我来说都一样!我是否缺少有关XML的内容-是否存在有趣的空白空间问题,大写字母,特殊字符,或者我的XML刚好包含奇怪的gremlin! 它现在正在工作,但是我想知道为什么。 这可行!<ScrollView
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:padding=\"10dip\">
<TextView
android:id=\"@+id/about_content\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"@string/about_text\" />
</ScrollView>
这不起作用:崩溃:java.lang.runtime.exception。二进制xml文件lin#1:您必须提供layout_width属性。
<ScrollView
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android.layout_width=\"fill_parent\"
android.layout_height=\"fill_parent\"
android:padding=\"10dip\">
<TextView
android:id=\"@+id/about_content\"
android.width =\"wrap_content\"
android.height =\"wrap_content\"
android:text=\"@string/about_text\"/>
</ScrollView>
解决方法
在无效的XML中,属性名称中有句点(
.
):
android.layout_width
和
android.layout_height
需要使用冒号(:
)代替:
android:layout_width
和
android:layout_height
,供以后参考,它们是可以用来帮助您发现假定相同文件之间差异的工具。 Liquid XML Editor是一种这样的工具,但是还有更多来自Microsoft的工具,该功能被形象地称为xml diff即xml差异。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。