ActionBar text color

后端 未结 24 3030
日久生厌
日久生厌 2020-11-22 05:31

how can I change the text color of the ActionBar? I\'ve inherited the Holo Light Theme, I\'m able to change the background of the ActionBar but I don\'t find out what is the

24条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 06:29

    A lot of answers are deprecated so I'll update the thread and show how to change text color and backgroundcolor on ActionBar (Toolbar) and in ActionBar pop up menu.

    The latest approach in Android (as of May 2018) in working with Action bar (Toolbar) is to use Theme with NoActionBar and use Toolbar instead.

    so here is what you need:

    1. In Activity (which extends AppCompatActivity) declare Toolbar:

      Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(myToolbar);
      
    2. Add Toolbar in the Activity's layout xml. Here we will set our custom (overwritten themes), note android:theme="@style/ThemeOverlay.AppTheme.ActionBar" and app:popupTheme="@style/ThemeOverlay.AppTheme.PopupMenu", they will do the trick.

      
      
    3. In your styles.xml you will have to overwrite those two styles to set custom colors:

      
      
      
      
      
      

    That's it folks

    p.s. if you ask me I would say: YES, this whole Theme thing is a hell of a mess.

提交回复
热议问题