使用卡片视图删除浮动操作按钮的灰色阴影颜色



这是我的布局:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/cardview"
app:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- contents here -->
</android.support.v7.widget.CardView>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/cardview"
app:elevation="5dp"
app:layout_anchorGravity="right|bottom">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
app:elevation="0dp" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

我想删除浮动动作按钮的灰色阴影颜色,我尝试了android:elevation="0dp",它删除了灰色阴影,但整个浮动动作按钮都放在卡片视图后面。

您的卡片视图具有一些默认提升。 通过将 app:cardElevation="0dp" 添加到您的卡片视图来删除它,它将正常工作

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/cardview"
app:cardElevation="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- contents here -->
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="0dp"
android:clickable="true"
android:focusable="true"
app:layout_anchor="@+id/cardview"
app:layout_anchorGravity="right|bottom"/>

最新更新