How to change programmatically background color of action bar items

后端 未结 3 1764
生来不讨喜
生来不讨喜 2021-01-12 06:45

It is easy to set a default color of the items background in action bar by setting:

@drawable/action_bar         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 07:08

    Use simple one line code... Pass RGB values of the required color

    getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(248, 248, 248)));
    

    For Color codes, you can use this website: http://www.rapidtables.com/web/color/RGB_Color.htm

提交回复
热议问题