android.view.Window.getStatusBarColor()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中android.view.Window.getStatusBarColor()方法的一些代码示例,展示了Window.getStatusBarColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getStatusBarColor()方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:getStatusBarColor

Window.getStatusBarColor介绍

暂无

代码示例

代码示例来源:origin: nickbutcher/plaid

public SystemChromeFader(Activity activity) {
  this.activity = activity;
  statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor());
  navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor());
  fadeNavBar = ViewUtils.isNavBarOnBottom(activity);
}

代码示例来源:origin: xinghongfei/LookLook

public SystemChromeFader(Activity activity) {
  this.activity = activity;
  if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
    statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor());
    navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor());
  }
  fadeNavBar = ViewUtils.isNavBarOnBottom(activity);
}

代码示例来源:origin: niorgai/StatusBarCompat

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (Math.abs(verticalOffset) > appBarLayout.getHeight() - collapsingToolbarLayout.getScrimVisibleHeightTrigger()) {
      if (window.getStatusBarColor() != statusColor) {
        startColorAnimation(window.getStatusBarColor(), statusColor, collapsingToolbarLayout.getScrimAnimationDuration(), window);
      }
    } else {
      if (window.getStatusBarColor() != Color.TRANSPARENT) {
        startColorAnimation(window.getStatusBarColor(), Color.TRANSPARENT, collapsingToolbarLayout.getScrimAnimationDuration(), window);
      }
    }
  }
});

代码示例来源:origin: nickbutcher/plaid

@Override
public void onDrag(float elasticOffset, float elasticOffsetPixels,
          float rawOffset, float rawOffsetPixels) {
  if (elasticOffsetPixels > 0) {
    // dragging downward, fade the status bar in proportion
    activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow()
        .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha)));
  } else if (elasticOffsetPixels == 0) {
    // reset
    activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(
        activity.getWindow().getStatusBarColor(), statusBarAlpha));
    activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha(
        activity.getWindow().getNavigationBarColor(), navBarAlpha));
  } else if (fadeNavBar) {
    // dragging upward, fade the navigation bar in proportion
    activity.getWindow().setNavigationBarColor(
        ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(),
            (int) ((1f - rawOffset) * navBarAlpha)));
  }
}

代码示例来源:origin: xinghongfei/LookLook

@Override
public void onDrag(float elasticOffset, float elasticOffsetPixels,
          float rawOffset, float rawOffsetPixels) {
  if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
    if (elasticOffsetPixels > 0) {
      // dragging downward, fade the status bar in proportion
      activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow()
          .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha)));
    } else if (elasticOffsetPixels == 0) {
      // reset
      activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(
          activity.getWindow().getStatusBarColor(), statusBarAlpha));
      activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha(
          activity.getWindow().getNavigationBarColor(), navBarAlpha));
    } else if (fadeNavBar) {
      // dragging upward, fade the navigation bar in proportion
      activity.getWindow().setNavigationBarColor(
          ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(),
              (int) ((1f - rawOffset) * navBarAlpha)));
    }
  }
}

代码示例来源:origin: ImmortalZ/TransitionHelper

if (activity.getWindow().getStatusBarColor() == 0 ||
    (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS & activity.getWindow().getAttributes().flags)
        == WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) {

代码示例来源:origin: matrixxun/ImmersiveDetailSample

@SuppressLint("NewApi")
public static void setStatusBarColorImmediately(Activity activity, int color){
  if(!isLollipop21More() || activity == null){
    return;
  }
  Window window = activity.getWindow();
  if(window != null){
    if(window.getStatusBarColor() != color){
      window.setStatusBarColor(color);
    }
  }
}

代码示例来源:origin: CityZenApp/Android-Development

private void getStatusBatColor() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getWindow();
    statusBatColor = window.getStatusBarColor();
  }
}

代码示例来源:origin: yugai/DouYu-Android

public SystemChromeFader(Activity activity) {
  this.activity = activity;
  statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor());
  navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor());
  fadeNavBar = ViewUtils.isNavBarOnBottom(activity);
}

代码示例来源:origin: 18Gray/ProCamera

@Override
  public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (Math.abs(verticalOffset) > appBarLayout.getHeight() - collapsingToolbarLayout.getScrimVisibleHeightTrigger()) {
      if (window.getStatusBarColor() != statusColor) {
        startColorAnimation(window.getStatusBarColor(), statusColor, collapsingToolbarLayout.getScrimAnimationDuration(), window);
      }
    } else {
      if (window.getStatusBarColor() != Color.TRANSPARENT) {
        startColorAnimation(window.getStatusBarColor(), Color.TRANSPARENT, collapsingToolbarLayout.getScrimAnimationDuration(), window);
      }
    }
  }
});

代码示例来源:origin: matrixxun/ImmersiveDetailSample

/**
 * 注意: 不要持续的调这个方法, 调一次就够了.
 * @param activity
 * @param toColor
 * @param msec
 */
@SuppressLint("NewApi")
public static void setStatusBarColorFade(final Activity activity, final int toColor, int msec) {
  if (activity == null || !isLollipop21More()) {
    return;
  }
  final Window window = activity.getWindow();
  if (window == null) {
    return;
  }
  int statusBarColor = window.getStatusBarColor();
  if (statusBarColor != toColor) {
    ValueAnimator statusBarColorAnim = ValueAnimator.ofObject(ARGB_EVALUATOR, statusBarColor, toColor);
    statusBarColorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        window.setStatusBarColor((Integer) animation
            .getAnimatedValue());
      }
    });
    statusBarColorAnim.setDuration(msec);
    statusBarColorAnim.setInterpolator(INTERPOLATOR_FAST_OUT_SLOW_IN);
    statusBarColorAnim.start();
  }
}

代码示例来源:origin: yugai/DouYu-Android

@Override
public void onDrag(float elasticOffset, float elasticOffsetPixels,
          float rawOffset, float rawOffsetPixels) {
  if (elasticOffsetPixels > 0) {
    // dragging downward, fade the status bar in proportion
    activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow()
        .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha)));
  } else if (elasticOffsetPixels == 0) {
    // reset
    activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(
        activity.getWindow().getStatusBarColor(), statusBarAlpha));
    activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha(
        activity.getWindow().getNavigationBarColor(), navBarAlpha));
  } else if (fadeNavBar) {
    // dragging upward, fade the navigation bar in proportion
    activity.getWindow().setNavigationBarColor(
        ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(),
            (int) ((1f - rawOffset) * navBarAlpha)));
  }
}

代码示例来源:origin: HuanTanSheng/EasyPhotos

private void adaptationStatusBar() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    int statusColor = getWindow().getStatusBarColor();
    if (statusColor == Color.TRANSPARENT) {
      statusColor = ContextCompat.getColor(this, R.color.colorPrimaryDark);
    }
    if (ColorUtils.isWhiteColor(statusColor)) {
      SystemUtils.getInstance().setStatusDark(this, true);
    }
  }
}

代码示例来源:origin: zendesk/belvedere

if (window.getStatusBarColor() == colorPrimaryDark) {
  final ValueAnimator animation = ValueAnimator.ofObject(new ArgbEvaluator(), colorPrimaryDark, statusBarColor);
  animation.setDuration(100);

代码示例来源:origin: baiiu/ZhihuDaily

public int getStatusBarColor() {
 if (belowKitKat()) {
  // On pre-kitKat devices, you can have any status bar color so long as it's black.
  return Color.BLACK;
 }
 if (hasL()) {
  return mActivity.getWindow().getStatusBarColor();
 }
 if (hasKitKat()) {
  ViewGroup contentView = (ViewGroup) mActivity.findViewById(android.R.id.content);
  View statusBarView = contentView.getChildAt(0);
  if (statusBarView != null && statusBarView.getMeasuredHeight() == ScreenUtil.getStatusHeight(
    mActivity)) {
   Drawable drawable = statusBarView.getBackground();
   if (drawable != null) {
    return ((ColorDrawable) drawable).getColor();
   }
  }
 }
 return -1;
}

代码示例来源:origin: listenzz/AndroidNavigation

window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (animated) {
  int curColor = window.getStatusBarColor();
  ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color);
  colorAnimation.addUpdateListener(

代码示例来源:origin: HuanTanSheng/EasyPhotos

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_puzzle_selector_easy_photos);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
      int statusColor = getWindow().getStatusBarColor();
      if(statusColor == Color.TRANSPARENT){
        statusColor =  ContextCompat.getColor(this, R.color.easy_photos_status_bar);
      }
      if (ColorUtils.isWhiteColor(statusColor)) {
        SystemUtils.getInstance().setStatusDark(this, true);
      }
    }
    albumModel = AlbumModel.getInstance();
//        albumModel.query(this, null);
    if (null == albumModel||albumModel.getAlbumItems().isEmpty()) {
      finish();
      return;
    }
    initView();
  }

代码示例来源:origin: PandaQAQ/MvpDemo

int statusBarColor = getWindow().getStatusBarColor();
mToolbarLayout.setContentScrimColor(statusBarColor);
if (statusBarColor != getWindow().getStatusBarColor()) {
  mToolbarLayout.setContentScrimColor(statusBarColor);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
      getWindow().getStatusBarColor(), statusBarColor);
  statusBarColorAnim.addUpdateListener(new ValueAnimator
      .AnimatorUpdateListener() {

代码示例来源:origin: Jerey-Jobs/KeepGank

.getStatusBarColor();
mToolbarLayout.setContentScrimColor(statusBarColor);
if (statusBarColor != ((AppCompatActivity) getActivity()).getWindow()
                             .getStatusBarColor()) {
  ValueAnimator statusBarColorAnim = ValueAnimator.ofArgb(
      ((AppCompatActivity) getActivity()).getWindow().getStatusBarColor(),
      statusBarColor);
  statusBarColorAnim.addUpdateListener(new ValueAnimator

代码示例来源:origin: vickychijwani/udacity-p1-p2-popular-movies

int statusBarColor = activity.getWindow().getStatusBarColor();
startColorAnimation(statusBarColor, primaryDarkColor, new ColorUpdateListener() {
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)

相关文章

微信公众号

最新文章

更多

Window类方法