Пример #1
0
 public void setScrimAlpha(@FloatRange(from = 0f, to = 1f) float alpha) {
   if (scrimAlpha != alpha) {
     scrimAlpha = alpha;
     scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha));
     ViewCompat.postInvalidateOnAnimation(this);
   }
 }
Пример #2
0
  public ParallaxScrimageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray a =
        getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView);
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) {
      scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) {
      scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) {
      maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha);
    }
    if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) {
      parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor);
    }
    a.recycle();

    scrimPaint = new Paint();
    scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha));
  }