【问题标题】:WebView tag in xml shows error in Eclipsexml 中的 WebView 标记在 Eclipse 中显示错误
【发布时间】:2014-06-20 04:31:47
【问题描述】:

为什么布局 xml 文件拒绝 WebView 标记。 带十字的红色圆圈显示在 xmlns:android="http://schemas.android.com/apk/res/android" 行中 并且应用程序无法启动。

谢谢

【问题讨论】:

  • 如果您将鼠标悬停在红叉上,它将显示错误。你能告诉我们它是什么吗?
  • 它说:为标签 WebView 找到了意外的命名空间前缀“xmlns”

标签: android xml eclipse layout webview


【解决方案1】:

我猜你已经将 xmlns 标签放在 webview 中,如下所示:

<WebView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

改成

<WebView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

xmlns:android 标签应该只添加到最外层的布局中。

至于我们为什么使用 xmlns:android,请阅读:Why this line xmlns:android="http://schemas.android.com/apk/res/android" must be the first in the layout xml file?

【讨论】:

  • 非常感谢!当 WebView 是布局中唯一的标签时它可以工作,但是当我将它放入 LinearLayout 时,出现错误。非常感谢您的快速回答!
猜你喜欢
  • 2012-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-22
  • 2015-02-18
相关资源
最近更新 更多