This Activity already has an action bar supplied by the window decor..... 报错

 Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

代码报错位置:

setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

最近使用recycleview的时候,下拉的时候出现顶部图片,标题也随着下滑。报了一个错

解决方法:在styles文件里添加

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

然后在

更改成AppTheme.NoActionBar

完工。

发布了95 篇原创文章 · 获赞 17 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_30299243/article/details/89365572