Android使用高斯模糊按钮视图(BlurButtonView)

144 阅读1分钟

截图

截图

GitHub

GitHub仓库

快速集成

添加依赖项

在模块的 build.gradle 中添加:

1dependencies {
   implementation 'com.qmdeve.blurview:core:1.1.3'
}

使用BlurButtonView

在XML布局中使用

<com.qmdeve.blurview.widget.QmBlurButtonView
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button Test"
        app:buttonCornerRadius="12dp"
        app:buttonIconPadding="8dp"
        app:buttonIconSize="24dp"
        app:buttonTextBold="true"
        app:blurRadius="12dp"
        app:overlayColor="#80FFFFFF"
        android:layout_below="@id/button1"
        android:layout_centerHorizontal="true"
        android:icon="?android:attr/actionModeWebSearchDrawable"
        app:buttonIconTint="@color/black"/>

属性说明

属性名类型默认值说明
app:buttonCornerRadiusdimension0设置Button的圆角半径
app:buttonIconPaddingdimension0dp设置Icon的内边距
app:buttonIconSizedimension-设置Icon大小
app:buttonTextBoldbooleantrueText是否粗体
app:blurRadiusdimension10模糊半径
app:overlayColorcolor#AAFFFFFF叠层颜色
app:buttonIconTintcolor-设置图标颜色
app:buttonTextColorPressedcolor-按下状态文本颜色
app:buttonTextColorDisabledcolor-禁用状态文本颜色
android:icon--设置图标
android:text--设置文本
android:textSize--Text大小

当然你也可以通过代码设置这些属性

不设置 android:text 则不显示文本

不设置 android:icon 则不显示图标


具体使用方法请查看GitHub


GitHub:github.com/QmDeve/QmBl…