这是我的布局:
<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>
我想删除FloatingActionButton的灰色阴影颜色,我尝试使用android:elevation="0dp"
,它会移除灰色阴影,但整个FloatingActionButton都会放在CardView后面。
答案 0 :(得分:0)
您的卡片视图有一些默认高程。通过添加app删除它:cardElevation =&#34; 0dp&#34;到您的卡片视图,它将正常工作
<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"/>