Adam Varhegyi
Adam Varhegyi

Reputation: 9924

FloatingActionButton has strange background in API 19

My FloatingActionButton works well in API 20+, but on API 19 I have this strange circle behind it.

enter image description here

You can see around the orange circle there is another rounded rectangle or I don't really know what is that... but it is there.

How could I hide that thing?

This only appears on API 19 (Android 4.4)

I use 'com.android.support:design:26.0.2'

Thanks in advance.

E D I T:

I don't use elevation.

XML source:

<?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>

Upvotes: 1

Views: 222

Answers (1)

Anton A.
Anton A.

Reputation: 1758

FAB is using shadow, LinearLayout not suitable for, because it wrap view content and ignore fab shadow.

FAB should be in RelativeLayout, FrameLayout (most suitable) or CoordinatorLayout. Wich as parent of FAB and main layout of view not wrap FAB size.

Basic usage of FAB in those is -

<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" />

Upvotes: 2

Related Questions