简体   繁体   English

如何更改 android 工具栏主页图标

[英]How can I change android Toolbar home icon

I trying to change the toolbar icons like Image 01 to Image 02 and similarly the back icon.我试图将Image 01之类的工具栏图标更改为Image 02以及类似的后退图标。

I am able to change the default icons color using我可以使用更改默认图标颜色

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/whit</item>
    <item name="colorPrimaryDark">@color/whit</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/IconStyle</item>
</style>

<style name="IconStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/name_heading</item>
</style>

I already try:我已经尝试过:

toolbar=findViewById(R.id.toolBarId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_right_select);

but now work.但现在工作。 Is there any way to solve it from the styles.xml file?有什么办法可以从styles.xml文件中解决吗?

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_arrow_right_select);

In kotlin:在 kotlin:

supportActionBar!!.setHomeAsUpIndicator(R.drawable.ic_back)

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

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