[英]How can I change android Toolbar home icon
我試圖將Image 01之類的工具欄圖標更改為Image 02以及類似的后退圖標。
我可以使用更改默認圖標顏色
<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>
我已經嘗試過:
toolbar=findViewById(R.id.toolBarId);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_right_select);
但現在工作。 有什么辦法可以從styles.xml文件中解決嗎?
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_arrow_right_select);
在 kotlin:
supportActionBar!!.setHomeAsUpIndicator(R.drawable.ic_back)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.