Android examples for User Interface:ActionBar Color
set ActionBarActivity Color
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.support.v7.app.ActionBarActivity; public class Main{ public static Drawable setColor(ActionBarActivity activity, int colorRes, Drawable oldBackground, Drawable.Callback drawableCallback) { Drawable colorDrawable = new ColorDrawable(colorRes); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) colorDrawable.setCallback(drawableCallback); else/*from w w w . j a v a2s. co m*/ activity.getSupportActionBar().setBackgroundDrawable( colorDrawable); } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) td.setCallback(drawableCallback); else activity.getSupportActionBar().setBackgroundDrawable(td); td.startTransition(200); } return colorDrawable; } }