androidandroid-drawer

How do i change Drawer item parents Text color?


How do i change the item parents Text color that's in the drawer? I would like to change the Profiles text Color since i can barely see it in the drawer.

enter image description here


Solution

  • Create a style for you navigationDrawer header in you styles.xml

     <style name="HeaderTextAppreance">
        <item name="android:textColor">@color/colorPrimary</item> 
     </style>
    

    and then in your activity access your navigation header with it's Id and then try this:

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    
        Menu menu = navigationView.getMenu();
    
        MenuItem tools= menu.findItem(R.id.yourId);
        SpannableString s = new SpannableString(tools.getTitle());
        s.setSpan(new TextAppearanceSpan(this, R.style.HeaderTextAppreance), 0, s.length(), 0);
        tools.setTitle(s);
        navigationView.setNavigationItemSelectedListener(this);