关闭

[转载] Android Studio Rendering Problems "android.support.v7.internal.widget.ActionBarOverlayLayout"

310人阅读 评论(0) 收藏 举报
分类:

Android Studio(以下简称AS) 1.2 
SDK 4.0

问题: 
新建一个Android项目,进入AS后没有显示 具体的手机设配,并给出提示:

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">The following classes could not be instantiated:
- android<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.support</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.v</span>7<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.internal</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.widget</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.ActionBarOverlayLayout</span> (Open Class, Show Exception, Clear Cache)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

解决办法: 
1. 打开AS 界面中,默认在AS左边的 “Project” 然后 “app->res->values->styles.xml” 
2. 找到 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
将后面的"Theme.AppCompat.Light.DarkActionBar" 修改为 "Base.Theme.AppCompat.Light.DarkActionBar" 回到AS中的activity_main.xml即可正常显示手机设备了;

原因: 
如果此时按 crtr+鼠标左键点击 Theme.AppCompat.Light.DarkActionBar AS会显示它的source:

<code class="hljs xml has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;"><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136);">style</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102);">name</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0);">"Theme.AppCompat.Light.DarkActionBar"</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102);">parent</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0);">"Base.Theme.AppCompat.Light.DarkActionBar"</span>/></span><span class="css" style="box-sizing: border-box;"></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

我们发现Theme.AppCompat.Light.DarkActionBarBase 的一个子类, 也就是Theme.AppCompat.Light.DarkActionBar继承了Base 所以styles.xml需要修改

转载自: ERROR :rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:9325次
    • 积分:86
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:16篇
    • 译文:0篇
    • 评论:0条
    文章分类