/**
  * 改变ActionBar color
  *
  * @param newColor 颜色值
  */
 private void setActionBarcolor(int newColor) {
   // 改变ActionBar颜色如果ActionBar是可用的
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     Drawable colorDrawable = new ColorDrawable(newColor);
     Drawable bottomDrawable = getResources().getDrawable(R.drawable.abc_ab_share_pack_mtrl_alpha);
     LayerDrawable ld = new LayerDrawable(new Drawable[] {colorDrawable, bottomDrawable});
     if (oldBackground == null) {
       if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
         ld.setCallback(drawableCallback);
       } else {
         getActionBar().setBackgroundDrawable(ld);
       }
     } else {
       TransitionDrawable td = new TransitionDrawable(new Drawable[] {oldBackground, ld});
       // 解决了破碎ActionBarContainer可拉的处理
       // pre-API 17 builds
       // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
       if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
         td.setCallback(drawableCallback);
       } else {
         getActionBar().setBackgroundDrawable(td);
       }
       td.startTransition(200);
     }
   }
 }
  @SuppressLint("NewApi")
  private void changeColor(int newColor) {

    tabs.setIndicatorColor(newColor);

    // change ActionBar color just if an ActionBar is available
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

      Drawable colorDrawable = new ColorDrawable(newColor);
      Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
      LayerDrawable ld = new LayerDrawable(new Drawable[] {colorDrawable, bottomDrawable});

      if (oldBackground == null) {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
          ld.setCallback(drawableCallback);
        } else {
          getActionBar().setBackgroundDrawable(ld);
        }

      } else {

        TransitionDrawable td = new TransitionDrawable(new Drawable[] {oldBackground, ld});

        // workaround for broken ActionBarContainer drawable handling on
        // pre-API 17 builds
        // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
          td.setCallback(drawableCallback);
        } else {
          getActionBar().setBackgroundDrawable(td);
        }

        td.startTransition(200);
      }

      oldBackground = ld;

      // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
      getActionBar().setDisplayShowTitleEnabled(false);
      getActionBar().setDisplayShowTitleEnabled(true);
    }

    currentColor = newColor;
  }