android编辑布局文件时非要降低api level或者更改主题才能显示布局预览 的根本解决办法

有时候在编辑android 布局文件时,不显示预览并且报错:

The following classes could not be instantiated: - android.support.v7.app.WindowDecorActionBar


每次都要降低api level或者修改app theme才能显示出预览


根本解决办法:找到你的res文件夹中 style.xml ,定义了AppTheme的地方


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

给他加上Base. 变成

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

注意,这样修改并不会造成什么影响,这样给appTheme定义的更精细
只是在编辑布局文件的时候不用修改api level 和app theme 就可以正常显示出预览了而已