Search code examples
androidxmlandroid-layout

Floating Action Button appearing as a square


I am currently working on an Android app and using the latest addition of the Floating Action Button. However, after compiling the necessary libraries and adding the fab into my xml file, it appears as a square while I am expecting it to be a circle, just like everywhere else.

I use the same basic code to implement the fab as found online and my result is a square and theirs is a nice circle fab.

Here is my code:

<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"
    android:src="@drawable/ic_person_add_black_24dp" />

Here is an screenshot of what is displayed:

screenshot

How to display the fab (add contact here) as a circle?

Thank you,


Solution

  • I don't know if this is what solved it but I stopped working on this project for another one for a little bit & I didn't have this problem on my other project.

    AndroidStudio seems to create a square fab if your activity extends Activity and not AppCompatActivity.