渲染期间引发异常:视图 android.support.v7.widget.Toolbar 未使用正确的上下文创建

Exception raised during rendering: View android.support.v7.widget.Toolbar not created with the right context

我在 Android 预览设计器中收到此错误消息 "Rendering Problems"。我正在使用 API 22 渲染并迁移到新的 API 支持 v4:22.1+ 和 v7:22.1+.

Rendering Problems Exception raised during rendering: View android.support.v7.widget.Toolbar not created with the right context

场景:

错误是因为我必须在工具栏布局中删除 "app" 部分并将 'app:' 更改为 'android:'。

删除:

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

替换:

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/Theme.AppCompat"

对于:

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:popupTheme="@style/Theme.AppCompat"

I solved this problem by Downgrading API level from 22,21 to 20 as shows in below image