1. 程式人生 > >Android Studio 新建專案無法檢視佈局檔案的問題

Android Studio 新建專案無法檢視佈局檔案的問題

Android Studio 新建專案出現的問題,最新版的AndroidStudio新建專案後可能在layout佈局檔案中預覽不了我們寫的佈局報下面錯誤

 Rendering Problems The following classes could not be instantiated:
- android.support.v7.internal.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or
show sample data when shown in the IDE Exception Details java.lang.ClassNotFoundException: android.support.v7.appcompat.R$attr Copy stack to clipboard

這裡寫圖片描述

百度搜搜尋的時候很少有類似的錯誤,大多說在File/Project Str8cture/app/Dependencies裡面新增v7包,實際預設已經添加了。解決起來很容易最簡單的方法就是修改主題,如下所示

解決方案

<resources>

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> </resources> <!-------------華麗的分割線------------------> <!--將Theme修改成為--> <resources> <!-- Base application theme. --> <style
name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. --> </style> </resources>

OK大功告成,再去看看,可以了吧。