错误: 呈现问题以下类无法找到 android.Support.v7.interal.widget. ActionBarOverlayLayout

我只是一个开发 Android 应用程序的初学者,当我在 Android Studio 1.1.0上创建一个新项目时, 它放弃了这个错误 ” 渲染问题 找不到下列类 android.support. v7.interal.widget. ActionBarOverlayout

现在我已经在谷歌上搜索这一点,我发现可能有3个解决方案的大多数人给出。

他们说:

  1. 要么将 api (从预览窗口窗格)从22更改为21,要么

  2. 将应用程序主题从“项目主题”更改为任何其他主题。

  3. 请确保在您的项目结构中导入了正确的 appcompat-v7库-> 依赖项, 请参考以下步骤: 将支持库特性项目标识符添加到依赖项部分。例如,要包含 appcompat 项目,请添加编译“ com.android.support: appcompat-v7:18.0。“ +”到依赖项部分,如下面的示例所示:

dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+" }

注意: 我的 android 支持库是最新的(使用 SDK Manager 安装)。

按照前两个步骤,删除错误。但我觉得这些都不是永久的解决方案,第二步似乎只是一个暂时的解决办法。我对第一步也有疑问,如果要删除这个错误,我们将 API 从22改为21,那么到最后,我们的应用将不能在 Android 5.1.1(API 22)中工作,它将仅限于 Android 5.0.1及以下(API 21)。我的怀疑有道理吗? 关于第三个步骤,它是这个问题的永久解决方案吗?

附注: 很抱歉标签不匹配,由于网站的声誉不允许添加确切的标签

97663 次浏览

Fix res/values/styles.xml like so:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>

Detailed explanation as requested: Theme.AppCompat.Light.DarkActionBar is a subclass of the superclass Base anyway. Ctrl+click (Android Studio) on it and you will be taken to the source:

<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />

We didn't change anything, we just defined it more precisely.

Modify src/res/values/styles.xml

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>

Then select API22, you'll find this problem fixed!

You don't need to change the theme. Maybe your're extending ActionBarActivity (deprecated) instead of just Activity. Change it, and build the project.

If you do change the activity from ActionBarActivity to just Activity, don't forget to import the Activity itself. That is

import android.app.Activity

It sucks but hey, it's their fault and not ours.

Also you can simply change the theme by pressing the "AppTheme" and choose Holo.Light.DarkActionBar. It updates the styles.xml file automatically.After that, rebuild the project.

I did all these and it works for me though i think them guys at Google and IntelliJ should do something about this rendering problem since we have been told to move from Eclipse to Android Studio

I fixed this problem by switching to the Holo Dark theme, then back to the App theme. I just clicked the button above the viewer that says App theme next to the rotate view in Android Studio. About 10% of the time, that alone doesn't work and I also have to change the API of the viewer from 22 to 19.

No idea why this works, but the suggestions provided above did not work for me.

After this error, I'm using :

API-22 Android 5.1.1 and still this problem exist.But you can at the top of the android studio toolbar, Choose:

Material Light -> Material Light

and then you can see the preview with Toolbar and light theme.

Hope this helps.

This is a known bug since Android Studio build 1.1 (it is also still in 1.2 and 1.3 preview). Switching the preview's API level from 22 to 21 fixes the for most people. While waiting for a fix you could try it as well.

enter image description here

Originally answered here : Rendering problems in Android Studio v 1.1 / 1.2

Just reposting