Skip to content

ProgressiveBlurView

使用组件

xml
<com.qmdeve.blurview.widget.ProgressiveBlurView
    android:layout_width="match_parent"
    android:layout_height="150dp"
    app:progressiveOverlayColor="#AAFFFFFF"
    app:progressiveDirection="topToBottom"
    app:progressiveBlurRadius="25dp" />
java
ProgressiveBlurView progressive = new ProgressiveBlurView(context);
progressive.setGradientDirection(ProgressiveBlurView.DIRECTION_TOP_TO_BOTTOM);
progressive.setBlurRadius(25f);
progressive.setOverlayColor(0xAAFFFFFF);
kotlin
val progressive = ProgressiveBlurView(context)
progressive.setGradientDirection(ProgressiveBlurView.DIRECTION_TOP_TO_BOTTOM)
progressive.setBlurRadius(25f)
progressive.setOverlayColor(0xAAFFFFFF.toInt())

属性说明

属性名类型默认值说明
app:progressiveOverlayColorcolor#AAFFFFFF渐变覆盖色。
app:progressiveDirectionenumtopToBottom渐变方向。可选:topToBottombottomToTopleftToRightrightToLeft
app:progressiveBlurRadiusdimension25dp渐变模糊使用的基础半径。
app:progressiveLayersinteger-已在 attrs 中声明,当前实现暂未使用。

API 参考

方法名说明
setGradientDirection(int)设置方向常量:DIRECTION_TOP_TO_BOTTOMDIRECTION_BOTTOM_TO_TOPDIRECTION_LEFT_TO_RIGHTDIRECTION_RIGHT_TO_LEFT
setOverlayColor(int)设置渐变覆盖色。
setOverlayColorRes(@ColorRes int)通过颜色资源设置渐变覆盖色。
setBlurRadius(float)设置渐变模糊半径。
setCornerRadius(float)在该组件中被重写为固定 0(不支持圆角模糊裁切)。