Skip to content

ProgressiveBlurViewGroup

ProgressiveBlurViewGroup 是带有方向渐进效果的模糊容器组件,可在整个容器区域内应用渐变强度的模糊遮罩。

使用组件

xml
<com.qmdeve.blurview.widget.ProgressiveBlurViewGroup
    android:id="@+id/progressiveContainer"
    android:layout_width="match_parent"
    android:layout_height="240dp"
    app:progressiveDirection="topToBottom"
    app:progressiveOverlayColor="#AAFFFFFF"
    app:progressiveBlurRadius="25dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Progressive Blur Group" />

</com.qmdeve.blurview.widget.ProgressiveBlurViewGroup>
java
ProgressiveBlurViewGroup group = new ProgressiveBlurViewGroup(context);
group.setGradientDirection(ProgressiveBlurViewGroup.DIRECTION_TOP_TO_BOTTOM);
group.setBlurRadius(25f);
group.setOverlayColor(0xAAFFFFFF);
kotlin
val group = ProgressiveBlurViewGroup(context)
group.setGradientDirection(ProgressiveBlurViewGroup.DIRECTION_TOP_TO_BOTTOM)
group.setBlurRadius(25f)
group.setOverlayColor(0xAAFFFFFF.toInt())

属性说明

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

API 参考

方法名说明
setGradientDirection(int)设置渐变方向。
setOverlayColor(int)设置渐变覆盖色。
setOverlayColorRes(@ColorRes int)通过颜色资源设置覆盖色。
setBlurRadius(float)设置渐进模糊半径。
setCornerRadius(float)在该组件中被重写为固定 0
setBlurRounds(int)继承:设置原生模糊迭代次数。
getBlurRounds()继承:获取原生模糊迭代次数。
setDownsampleFactor(float)继承:设置下采样系数。
setTopLeftCornerRadius(float)继承:圆角控制接口。
setTopRightCornerRadius(float)继承:圆角控制接口。
setBottomLeftCornerRadius(float)继承:圆角控制接口。
setBottomRightCornerRadius(float)继承:圆角控制接口。
getBlurredBitmap()继承:获取最近一次模糊位图。
release()继承:释放模糊资源。