简体   繁体   English

CardView 背景模糊和透明? 安卓工作室

[英]CardView background blur and transparent? Android Studio

I'm trying to make this:我正在努力做到这一点:

在此处输入图片说明

and this is what I'm getting:这就是我得到的:

在此处输入图片说明

I can't make the background blur and transparent at the same time, how could I do that?我不能同时使背景模糊和透明,我该怎么做?

when I try to do it with "alpha" it removes opacity in the text as well, which does not happen in the original photo.当我尝试用“alpha”来做它时,它也会删除文本中的不透明度,这在原始照片中不会发生。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/tools"
    android:fitsSystemWindows="true">

    <androidx.cardview.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:cardCornerRadius="10dp"
        android:layout_gravity="center|top"
        android:layout_margin="8dp"
        card_view:cardElevation="0dp">

        <androidx.cardview.widget.CardView
            android:layout_width="180dp"
            android:layout_height="wrap_content"
            app:cardCornerRadius="2dp"
            android:layout_gravity="top"
            android:layout_marginTop="130dp"
            android:layout_marginStart="50dp"
            card_view:cardBackgroundColor="@android:color/transparent"
            card_view:cardElevation="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="For example"
                android:layout_gravity="center"
                android:textColor="@color/colorAccent"
                android:textStyle="bold" />
        </androidx.cardview.widget.CardView>
        

        <LinearLayout
            android:layout_width="280dp"
            android:layout_height="180dp"
            android:orientation="vertical">
            

            <ImageView
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="180dp"
                android:src="@drawable/imagen1"
                android:scaleType="centerCrop"/>
            
        </LinearLayout>

    </androidx.cardview.widget.CardView>
    
</androidx.coordinatorlayout.widget.CoordinatorLayout>

You have use BlurKit Layout Inside Card View .您已经在 Card View 中使用了 BlurKit Layout。 Change Your Card View Content Like This .像这样更改您的卡片视图内容。

   <androidx.cardview.widget.CardView
    android:id="@+id/spdv_details_cv"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:cardCornerRadius="20dp"
    app:cardElevation="0dp"

    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:cardBackgroundColor="#23FFFFFF"
    app:layout_constraintHeight_percent="0.5"
    android:layout_margin="20dp"
    >
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <io.alterac.blurkit.BlurLayout
        android:id="@+id/blurLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        
        app:blk_blurRadius="1"

        app:blk_fps="1" />
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >



        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:background="@android:color/transparent"
            android:text="Awais Ahmed"

            android:textColor="@color/black"
            android:textSize="23sp"

            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"/>
    </androidx.constraintlayout.widget.ConstraintLayout>
    </FrameLayout>

</androidx.cardview.widget.CardView>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM