简体   繁体   中英

Floating Action Button (FAB) appears in rectangle shape by default - Android Studio

I've been working on a android app which requires FAB. When I try to add FAB it appears rectangle instead of circle. How to get the circle shape by default.

I added the implementation 'com.google.android.material:material:1.1.0 dependency in gradle

矩形浮动动作按钮
fab.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ProjectListActivity">

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent">

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="32dp"
        android:clickable="true"
        android:src="@drawable/ic_add_black_24dp"
        android:backgroundTint="@color/colorPrimary"
        app:fabSize="normal"
        app:rippleColor="@color/colorPrimaryDark" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

first:Restart Andriod studio second: make clean project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM