Utils.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:polar-dashboard 作者:
public static Drawable createCardSelector(Context context) {
  final int accentColor = DialogUtils.resolveColor(context, R.attr.colorAccent);
  final boolean darkTheme = Config.get().darkTheme();
  final int activated = TintUtils.adjustAlpha(accentColor, darkTheme ? 0.5f : 0.3f);
  final int pressed = TintUtils.adjustAlpha(accentColor, darkTheme ? 0.75f : 0.6f);

  final StateListDrawable baseSelector = new StateListDrawable();
  baseSelector.addState(new int[] {android.R.attr.state_activated}, new ColorDrawable(activated));

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    return new RippleDrawable(
        ColorStateList.valueOf(accentColor), baseSelector, new ColorDrawable(Color.WHITE));
  }

  baseSelector.addState(new int[] {}, new ColorDrawable(Color.TRANSPARENT));
  baseSelector.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(pressed));
  return baseSelector;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号