【问题标题】:Unbound Prefix Error when XML Parsing in Eclipse在 Eclipse 中解析 XML 时出现未绑定前缀错误
【发布时间】:2015-11-11 20:30:16
【问题描述】:

我想将工具栏小部件添加到我的应用程序。因此,当我将 xml 代码添加到布局文件时,我得到了 Unbound prefix 错误。我该怎么做才能解决这个问题?

我的布局.xml

    <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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.dizikolikk.MainActivity" >


<android.support.v7.widget.Toolbar

   android:id="@+id/my_toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="?attr/colorPrimary"
   android:elevation="4dp"
   android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
   app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

</RelativeLayout>

【问题讨论】:

    标签: android xml android-layout layout toolbar


    【解决方案1】:

    当您在 XML 布局中使用未定义的命名空间(在本例中为“app”命名空间)时,会发生此错误

    您需要添加

    xmlns:app="http://schemas.android.com/apk/res-auto"
    

    到您的 XML 布局。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      • 2015-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      • 2012-08-07
      相关资源
      最近更新 更多