xamarin.android - [Xamarin.Forms][Android] Change back and next color in navigation -


i' have navigation page , want override color button , next button ( toolbaritem )

i tried bartextcolor property change color navigation header text.

it's done in ios, i' not able find solution android.

it works title not icons.

here code :

protected override void onelementpropertychanged(object sender, propertychangedeventargs e) {     base.onelementpropertychanged(sender, e);      var page = this.element navigationpage;     if (page != null && toolbar != null)     {         toolbar.settitletextcolor(color.black.toandroid());          if (toolbar.navigationicon != null)             toolbar.navigationicon.setcolorfilter(color.green.toandroid(), android.graphics.porterduff.mode.multiply);          if (toolbar.overflowicon != null)             toolbar.overflowicon.setcolorfilter(color.green.toandroid(), android.graphics.porterduff.mode.multiply);     }     } 

i' have navigation page , want override color button , next button ( toolbaritem )

your next button toolbaritem, defined yourself. won't problem customize it. difficult part lies in button, because offered xamarin.forms. need override navigationpagerenderer change color:

public class mynavigationpagerenderer : navigationpagerenderer {     protected override void onelementchanged(elementchangedeventargs<navigationpage> e)     {         base.onelementchanged(e);         if (e.newelement != null)         {             var navcontroller = (inavigationpagecontroller)e.newelement;             navcontroller.pushrequested += navcontroller_pushrequested;             navcontroller.poprequested += navcontroller_poprequested;         }     }      private void navcontroller_poprequested(object sender, xamarin.forms.internals.navigationrequestedeventargs e)     {         device.starttimer(timespan.frommilliseconds(220), () =>         {             changeiconcolor();             return false;         });     }      private void navcontroller_pushrequested(object sender, xamarin.forms.internals.navigationrequestedeventargs e)     {         changeiconcolor();     }      private void changeiconcolor()     {         int count = this.viewgroup.childcount;          var toolbar = gettoolbar();          if (toolbar.navigationicon != null)         {             var drawable = (toolbar.navigationicon drawerarrowdrawable);             drawable.color = resource.color.material_grey_850;//set navigation icon color here         }     }      private atoolbar gettoolbar()     {         (int = 0; < this.viewgroup.childcount; i++)         {             var child = this.viewgroup.getchildat(i);             if (child atoolbar)             {                 return (atoolbar)child;             }         }          return null;     } } 

a little explanation codes above: pushrequest , poprequest fires when push , pop new page navigation page , perfect time customize existing toolbar's navigationicon. first find toolbar using gettoolbar change icon color changeiconcolor.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -