ActionBar text color

后端 未结 24 2653
日久生厌
日久生厌 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:09

    This function works well

    private void setActionbarTextColor(ActionBar actBar, int color) {
    
        String title = actBar.getTitle().toString();
        Spannable spannablerTitle = new SpannableString(title);
        spannablerTitle.setSpan(new ForegroundColorSpan(color), 0, spannablerTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        actBar.setTitle(spannablerTitle);
    
    }
    

    then to use it just feed it your action bar and the new color ie

    ActionBar actionBar = getActionBar();    // Or getSupportActionBar() if using appCompat
    int red = Color.RED
    setActionbarTextColor(actionBar, red);
    

提交回复
热议问题