我正在尝试将我的应用程序转换为操作栏。我正在关注 Google's tutorial .不幸的是,在尝试构建应用程序时,AAPT 返回以下错误:
menu.xml:6: AAPT: Error parsing XML: unbound prefix
我做了一些研究,发现这个错误通常发生在行 xmlns:android="http://schemas.android.com/apk/res/android"
不包括在内时在 XML 中,因为 AAPT 不知道如何解释 android.xxx
标签。但是,正如您从我的代码中看到的那样,我在第一个节点中包含了这一行:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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"/>
</LinearLayout>
那么为什么不能编译呢?
最佳答案
您还没有通过xmlns:app
声明app
命名空间,但您在app:popupTheme
中使用了它。 IIRC,在 Android Studio 中有一个快速修复。如果没有,请将 xmlns:app="http://schemas.android.com/apk/res-auto"
添加到您的根元素。
关于android - AAPT : error parsing XML: unbound prefix although namespace is defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49511916/