Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My FloatingActionButton has some weird lines coming out of it on 4.4 and lower

As the title says, my FloatingActionButton has some weird lines coming out of it only on 4.4 or lower. On Lollipop it works fine.

This is a picture of the issue:

FAB

The play image doesn't have those lines in it. My xml:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:src="@drawable/ic_av_play_arrow"
            app:borderWidth="0dp"
            app:elevation="6dp"
            app:layout_anchor="@+id/image"
            app:layout_anchorGravity="center_vertical|right|end"
            app:rippleColor="@color/color_primary_light" />

So what am I doing wrong?

EDIT: goes away if I set my elevation to 0dp so I think I'll do that just for older phones

like image 477
casolorz Avatar asked Jul 08 '15 21:07

casolorz


People also ask

What is a floating icon?

Floating action buttons are UI controls for Android and web-based apps. A floating action button is a tool that allows users to navigate the key parts of an app or website. Usually, floating menu plugins display as a circular icon with the app's color scheme.

What is floating action button in Android?

A floating action button (FAB) is a circular button that triggers the primary action in your app's UI. This page shows you how to add the FAB to your layout, customize some of its appearance, and respond to button taps.

What is extended floating action button?

A floating action button (FAB) performs the primary, or most common, action on a screen. It appears in front of all screen content, typically as a circular shape with an icon in its center. Extended Floating Action Button is the newly introduced class with Material Components library in Android.


1 Answers

Your problem here is that you're making the FloatingActionButton an unexpected size. The FloatingActionButton in the support library only supports two sizes, and it must be set using the fabSize attribute.

You should change:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="48dp"
            android:layout_height="48dp"

to be:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

If you want a smaller version:

<android.support.design.widget.FloatingActionButton
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fabSize="mini"

Source: http://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html

like image 76
Kevin Coppock Avatar answered Sep 23 '22 05:09

Kevin Coppock