public void setScrimAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { if (scrimAlpha != alpha) { scrimAlpha = alpha; scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha)); ViewCompat.postInvalidateOnAnimation(this); } }
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)); }