错误:在包“com.example ...”中找不到属性'popupTheme'的资源标识符
问题描述:
有很多类似于此的问题,但我没有具体到我的代码。他们都没有为此工作。错误:在包“com.example ...”中找不到属性'popupTheme'的资源标识符
我想添加一个工具栏显示here
但因为它显示了我的错误
No resource identifier found for attribute 'popupTheme' in package "com.example...
这并没有为我工作
我的代码是这样的:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/LinearLayoutMain"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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>
我还添加了appcompat
和cardview
库,但仍然收到相同的错误。
有人知道答案吗?请回复。
答
在style.xml
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
变化
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
定义如下风格
app:popupTheme="@style/AppTheme.PopupOverlay"
希望它会帮助你。从应用
答
移除应用:风格 在写作风格上<style name="Theme ovelrlay... Your style name" parent="Widget.AppCompat.Toolbar"> <item name="android:background">@color/green</item> <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="theme">@style/ThemeOverlay.AppCompat.Dark</item> </style>
它应该工作正常 勾选答案正确感谢
Vidhi嗨,这是不可能的,除非你分享你的Java代码以及调试此。除此之外,如果你可以共享logcat堆栈跟踪,那么它会更好。可能你正在搞乱java代码中的一些布局通货膨胀。 –
虽然在你的xml中你可以尝试删除两个主题属性。这可能会给你一些没有错误的结果。 –