美文网首页
Toolbar坑

Toolbar坑

作者: dev晴天 | 来源:发表于2018-08-08 17:44 被阅读0次
//初始化UI控件
    private void initUI() {
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);// 为toobar设置actionbar 的支持
        ActionBar ab = getSupportActionBar();
        //ab.setHomeAsUpIndicator(R.drawable.menu);//  设置toolbar 的最左侧图标  默认情况下为(android.R.drawable.home)返回箭头
        ab.setDisplayHomeAsUpEnabled(true);// 设置是否显示最左侧的图标
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    }

报错:

 [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 t]



解决:
进入:

image.png

进入:


image.png

去掉actionbar 即可

相关文章

网友评论

      本文标题:Toolbar坑

      本文链接:https://www.haomeiwen.com/subject/uyvxbftx.html