与AppCompat-V7 21的动作条/工具栏显示图标工具栏、图标、动作、AppCompat

2023-09-12 00:43:21 作者:到最后忘了自己

我尝试了这些 - 但仍然没有看到这样的图标之前:

I tried these - but still do not see the icon like before:

getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

看来,当我使用自定义工具栏的工作 - 但是,这将迫使我摸所有布局 - 有没有更好的方式来做到这一点。

It seems to work when I use custom toolbar - but that would force me to touch all layouts - is there a better way to do so?

推荐答案

getSupportActionBar()setDisplayShowHomeEnabled(真);

以及

getSupportActionBar()的setIcon(R.drawable.ic_launcher);