Search code examples
androidandroid-studionavigation-drawer

I want to change one item(color & icon) in menu navigation bar or add text (New with red color)


I want to change text and icon color of navigation drawable and add new Word with diffrent color Can this is posible ? I am using android navigationview with navigation drawable i can change text with this

SpannableString spannableString = new SpannableString(" Invite Friends New");
    spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.kart)), 0, spannableString.length(), 0);
     navigationView.getMenu().findItem(R.id.invite_friends)
   .setTitle(spannableString);

I want that Invite friends in black color and new word is in red color is this possible ? & how to change icon color


Solution

  • I think it's posseble just u need to add html code like

        SpannableString spannableString = new SpannableString(Html.fromHtml("<font color=#090a0a>Invite Friends </font><font color=#e00a02>New</font>");
    spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.kart)), 0, spannableString.length(), 0);
     navigationView.getMenu().findItem(R.id.invite_friends)
    .setTitle(spannableString);
    

    hope will help you that .