AndroidStudio更新后,新建xml文件会发现布局无法正常预览,同时会在布局下面提示“The following classes could not be instantiated”等信息,通过查询资料都说要将style
文件夹下主题从
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
改为
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
但仔细看了一下项目主题,都是使用的Theme.AppCompat.Light.NoActionBar
,一筹莫展之际点击布局
xml居然正常预览了,特此记录一下!!