Android: AppCompat 21, how to change the back icon and the overflow icon to a custom one? -


on project until days ago used sherlock actionbar dicided change whole actionbar style new material design. on old theme , overflow icon had custom icons setted on theme. on appcompat tried define on theme use on toolbar it's not working. knows how make possible?

my theme use on toolbar(generated asset studio):

<style name="theme.themewiz" parent="@style/theme.appcompat.light.darkactionbar">     <item name="android:actionbarstyle">@style/actionbar.solid.themewiz</item>      <item name="android:actionbaritembackground">@drawable/selectable_background_themewiz</item>     <item name="android:popupmenustyle">@style/popupmenu.themewiz</item>     <item name="android:dropdownlistviewstyle">@style/dropdownlistview.themewiz</item>     <item name="android:actionbartabstyle">@style/actionbartabstyle.themewiz</item>     <item name="android:actiondropdownstyle">@style/dropdownnav.themewiz</item>     <item name="android:actionmodebackground">@drawable/cab_background_top_themewiz</item>     <item name="android:actionmodesplitbackground">@drawable/cab_background_bottom_themewiz</item>     <item name="android:actionmodeclosebuttonstyle">@style/actionbutton.closemode.themewiz</item>              <!-- light.darkactionbar specific -->     <item name="android:actionbarwidgettheme">@style/theme.themewiz.widget</item>      <item name="android:actionoverflowbuttonstyle">@style/theme.appcompat.overflow</item>  </style>  <style parent="@style/widget.appcompat.actionbutton.overflow" name="theme.appcompat.overflow">      <item name="android:src">@drawable/ic_action_overflow</item>  </style> 

toolbar xml:

<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/my_awesome_toolbar"     android:layout_height="wrap_content"     android:layout_width="match_parent"     android:minheight="?attr/actionbarsize"     android:background="?attr/colorprimarydark"     app:theme="@style/theme.themewiz"     app:popuptheme="@style/themeoverlay.appcompat.light"/> 

using appcompat 21 acheive these pretty easy.

to change icon, you'd have use support toolbar actionbar instead. this post chris banes should started.

once you're done adding toolbar, have is:

toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar_id); toolbar.setnavigationicon(r.drawable.back_icon); 

to change overflow icon on other hand, easiest way add custom style main theme declaration. like:

<resources>     <!-- base application theme. -->     <style name="your.theme" parent="@style/theme.appcompat">         <!-- theme items go here -->          <item name="actionoverflowbuttonstyle">@style/overflow</item>     </style>      <!-- styles -->     <style name="overflow" parent="@android:style/widget.appcompat.actionbutton.overflow">         <item name="android:src">@drawable/overflow_icon</item>     </style>  </resources> 

hope helps.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -