简体   繁体   English

如何在此特定代码中向操作栏添加小图标

[英]How Can i add little icon to actionbar in this specific code

I've been searching for many questions, but there were not proper for myself. 我一直在寻找许多问题,但对我来说并不适合。

I need one line to code to this: 我需要一行代码对此进行编码:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>
<style name="MyActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:background">#547AF7</item>
</style>

PROBLEM: How to add little icon on the left 问题:如何在左侧添加小图标

edit () I do not know why this doesnt work : 编辑()我不知道为什么这不起作用:

<item name="icon">@drawable/icon</item>

The use of application icon and title is discouraged in API Level 21, according to material design guidelines. 根据材料设计指南,在API级别21中不建议使用应用程序图标和标题。

But if you want to set icon, you could use setLogo() method of Toolbar. 但是,如果要设置图标,则可以使用工具栏的setLogo()方法。

You might want to use: 您可能要使用:

<item name="android:background">@drawable/YOURIMAGENAMEHERE</item>

Or read this: https://developer.android.com/training/basics/actionbar/styling.html 或阅读以下内容: https : //developer.android.com/training/basics/actionbar/styling.html

You can add icon on ActionBar using android:icon="@drawable/your_icon.png" 您可以使用android:icon="@drawable/your_icon.png"在ActionBar上添加图标

<application> or <activity> tags in your app manifest. 应用清单中的<application> or <activity>标签。

for more See the documentation : 有关更多信息,请参见文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM