コード例 #1
0
  private void updateActionBar(int offset) {

    avatarView.setOffset(offset);

    ActionBar bar = ((BaseActivity) getActivity()).getSupportActionBar();
    int fullColor = baseColor;
    ActorStyle style = ActorSDK.sharedActor().style;
    if (style.getToolBarColor() != 0) {
      fullColor = style.getToolBarColor();
    }

    if (Math.abs(offset) > Screen.dp(248 - 56)) {
      bar.setBackgroundDrawable(new ColorDrawable(fullColor));
    } else {
      float alpha = Math.abs(offset) / (float) Screen.dp(248 - 56);

      bar.setBackgroundDrawable(
          new ColorDrawable(
              Color.argb(
                  (int) (255 * alpha),
                  Color.red(fullColor),
                  Color.green(fullColor),
                  Color.blue(fullColor))));
    }
  }