我如何使用一个图标,而不是在Android工具栏的标题? [英] How can I use an icon instead of a title in the Android Toolbar?
本文介绍了我如何使用一个图标,而不是在Android工具栏的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过应用程序兼容性使用工具栏(而不是动作条)。我想用一个图标来代替工具栏的标题(应用程序/ actity名),但我看不出如何。
I'm using the Toolbar (instead of ActionBar) via AppCompat. I'd like to replace the Toolbar's title (the app/actity name) with an icon, but I don't see how.
我的图标,只是文字使用非标准字体,所以我想它可能在材料设计是允许的。
My icon is just text using a non-standard font, so I guess it might be allowed in Material Design.
推荐答案
使用以下步骤:
- 工具栏工具栏=(栏)findViewById(R.id.tool1);
- setSupportActionBar(工具栏);
- 将getSupportActionBar()删除标题setDisplayShowTitleEnabled(假);
- 添加您的标志,在RES /绘绘制文件夹中。
- 添加使用toolbar.setLogo(R.drawable.ic_launcher)标识;
这篇关于我如何使用一个图标,而不是在Android工具栏的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文