How to change action bar title color in code

前端 未结 6 1270
陌清茗
陌清茗 2020-11-27 05:28

I\'m having trouble changing androids action bar title color programmatically for v11 and up. I can get it done in xml but need to change it dynamically in code. How should

6条回答
  •  無奈伤痛
    2020-11-27 06:15

    If using the v7 appcompat library (tested with r22) then you can call setTitleTextColor() on the Toolbar object that substitutes the action bar for all API levels. For example:

    Toolbar actionBarToolbar = (Toolbar)activity.findViewById(R.id.action_bar);
    if (actionBarToolbar != null)
        actionBarToolbar.setTitleTextColor(Color.RED);
    

提交回复
热议问题