1. 程式人生 > >Failed to load AppCompat ActionBar with unknown error

Failed to load AppCompat ActionBar with unknown error

問題描述:

在Android studio中對應activity的xml的preview中,不能正常顯示佈局的設計,提示錯誤

The following classes could not be instantiated: - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache) - android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache) - android.support.v7.app.WindowDecorActionBar (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.

If this is an unexpected error you can also try to build the project, then manually refresh the layout.

修改方法: 在style資原始檔中,將

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

修改成:

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

然後測試可以顯示對應的佈局!