使用 Android Studio 中的模糊库向视图添加模糊

问题描述

我正在 Android Studio 中制作一个应用程序,我想使用 CardView 库将 Blur 添加Blurry。以前我是通过降低 CardView 的不透明度来实现的(这不是我一开始想要的,我想添加模糊等效果但没有找到要做什么)但是在此 CardView 中添加文本或其他内容时它也建立了不透明度,我真的不喜欢它。然后我找到了这个库,但我不会理解文档,因为我是移动应用程序开发的新手。

这是XML


 <androidx.constraintlayout.widget.ConstraintLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/constraintLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/gradient_animation"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="0dp"
        android:layout_height="175dp"
        android:orientation="horizontal"
        android:padding="10dp"
        app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <androidx.cardview.widget.CardView
            android:id="@+id/Recetas"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:id="@+id/Ingredientes"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </androidx.cardview.widget.CardView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="175dp"
        android:orientation="horizontal"
        android:padding="10dp"
        app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <androidx.cardview.widget.CardView
            android:id="@+id/Gastos"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="15dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:id="@+id/Ventas"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </androidx.cardview.widget.CardView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="0dp"
        android:layout_height="175dp"
        android:layout_marginBottom="40dp"
        android:orientation="horizontal"
        android:padding="10dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </RelativeLayout>
        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:alpha="0.26"
            android:backgroundTint="@color/colorButton"
            app:cardCornerRadius="15dp"
            app:cardElevation="10dp" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </RelativeLayout>
        </androidx.cardview.widget.CardView>
    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

因此,我想要做的是使用名为 Blur 的库为每个 CardView(其行为类似于按钮)添加模糊效果

有人能帮我知道如何用那个库添加模糊吗?或者,您是否知道其他任何有效的方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...