微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用 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 举报,一经查实,本站将立刻删除。