設置ActionBar的顏色

ActionBar的顏色有多種,包括自身的背景色,標題title的顏色,以及item項的文字顏色,控件的顏色都可以在xml中設置屬性,主要是自身的背景色和titile的背景色的設置

1.自身背景色的設置:

      使用以下代碼:

      mActionBar.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.bg_action_bar_normal));

2.title背景色的設置:

     使用一下代碼:

     int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView title = (TextView) findViewById(titleId);
title.setTextColor(this.getResources().getColor(R.color.red));

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章