设置ActioinBar 的背景色以及Title的字体颜色

     //设置ActionBar背景

        Drawable draw=this.getResources().getDrawable(R.drawable.actionbar_bg);

        getActionBar().setBackgroundDrawable(draw);
    
//设置ActionBar Title字体的颜色 int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); TextView title = (TextView)findViewById(titleId); title.setTextColor(this.getResources().getColor(R.color.white));

drawable/actionbar_bg.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

     android:shape="rectangle">

    <solid android:color="@color/actionbar_bg_color"/>

</shape>

valuues/colors.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>

    <!-- ActionBar Background Color -->

    <color name="actionbar_bg_color">#0565CC</color>

</resources>

 

你可能感兴趣的:(IO)