FloatingActionButton在API 19中具有奇怪的背景

时间:2018-07-06 11:39:41

标签: android android-support-library android-support-design

我的FloatingActionButton在API 20+上运行良好,但是在API 19上却有一个奇怪的圆圈。

enter image description here

您可以看到橙色圆圈周围的另一个圆角矩形,或者我真的不知道那是什么...但是它在那里。

我怎么藏那东西?

仅出现在API 19(Android 4.4)

我使用'com.android.support:design:26.0.2'

谢谢。

E D I T:

我不使用海拔。

XML源:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:clipChildren="false"
    android:clipToPadding="false"
    android:orientation="vertical"
    android:padding="8dp">



    <android.support.design.widget.FloatingActionButton

        android:id="@+id/stream_toggle_btn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/ic_stream_video_white" />


</LinearLayout>

1 个答案:

答案 0 :(得分:2)

FAB使用阴影,LinearLayout不适合使用阴影,因为它包装了视图内容并忽略了fab阴影。

FAB应该位于RelativeLayoutFrameLayout(最合适)或CoordinatorLayout中。作为FAB的父级,视图的主要布局未包装FAB大小。

FAB在其中的基本用法是-

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    app:fabSize="normal"
    app:srcCompat="@drawable/ic_add_white_24dp" />