You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

透明FAB下方出现奇怪白色圆角矩形的解决求助

透明FAB下方出现奇怪白色圆角矩形的解决求助

我最近在给Extended Floating Action Button和普通Floating Action Button添加透明效果时碰到了个棘手的问题:按钮下方似乎总有一个底层Drawable存在,在实际APP里这个问题更明显,会让按钮的背景看起来比预期更浅。

我在网上搜了很多方案,大家都提到这是系统默认的阴影Drawable,只需要把elevation和translationZ设为0就能解决,但我照做之后这个问题依然存在。

以下是我当前的布局代码:

<eightbitlab.com.blurview.BlurView 
    android:id="@+id/upload_items_blur" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toStartOf="parent"
    app:blurOverlayColor="@android:color/transparent" 
    android:background="@drawable/blur_background" 
    android:layout_marginBottom="16dp" >

    <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton 
        android:id="@+id/main_fab" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:icon="@drawable/ic_add_24" 
        android:text="Upload Items" 
        android:textColor="@color/white"
        app:backgroundTint="#CC1B1B3A" 
        app:iconTint="@color/white" 
        app:rippleColor="@color/brandeisblue"
        android:elevation="0dp" 
        android:translationZ="0dp" />
        
</eightbitlab.com.blurview.BlurView>

<com.google.android.material.floatingactionbutton.FloatingActionButton 
    android:id="@+id/search_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:tooltipText="Search" 
    android:contentDescription="Search" 
    android:src="@drawable/ic_search_24"
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toEndOf="@+id/upload_items_blur"
    app:layout_constraintBottom_toBottomOf="parent" 
    android:layout_marginBottom="16dp"
    app:tint="@color/white" 
    app:backgroundTint="#CC1B1B3A"
    android:elevation="0dp" 
    android:translationZ="0dp" />

另外,这里是我用到的blur_background Drawable代码,我试过移除这个背景,但问题还是没得到解决:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <solid android:color="@android:color/transparent" />
    <corners android:radius="16dp" />
</shape>

现在我希望找到解决这个问题的方法,要么能:

  • A. 彻底移除这个奇怪的底层Drawable;
  • B. 至少让这个底层Drawable和目标FAB的尺寸保持一致,让按钮整体看起来统一协调。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 09:34:29