Skip to content Skip to sidebar Skip to footer

Why Is My Floating Action Button Not Displaying Properly?

My floating button image looks like this It's a smaller button inside a larger circle, How do I fix this? layout file:

Solution 1:

I answered your previous question so I think I have realised what you missed here. Have a look at this image. You have accidentally added the Add circle. Add the selected one with 24dp or 48dp with white color it will workhave a look at this image. You have accidentally added the Add circle. Add the selected one with 24dp or 48dp with white color it will work]1

Solution 2:

Got Solution For You But I am not recommend it

create one vector file for icon color ic_circle.xml

<?xml version="1.0" encoding="utf-8"?><vectorandroid:height="40dp"android:viewportHeight="24"android:viewportWidth="24"android:width="40dp"xmlns:android="http://schemas.android.com/apk/res/android"><pathandroid:fillColor="@android:color/black"android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h"/></vector>

create second vector file for same color of float button your ic_add_circle_black_50dp.xml

<vector android:height="50dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="50dp" xmlns:android="http://schemas.android.com/apk/res/android">

create layer-list entries let say layer_list.xml

<?xml version="1.0" encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:drawable="@drawable/ic_circle"android:top="5dp"android:left="5dp"android:right="5dp"android:bottom="5dp"android:gravity="center"/><itemandroid:drawable="@drawable/ic_add_circle_black_50dp"android:height="55dp"android:width="55dp"/></layer-list>

Now Modify your FloatButton in xml as

<android.support.design.widget.FloatingActionButton
    android:id="@+id/addToKitchenButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    android:layout_gravity="bottom|end"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:src="@drawable/layer_list" />

Post a Comment for "Why Is My Floating Action Button Not Displaying Properly?"