浮动操作按钮(FAB)默认显示为矩形-Android Studio

时间:2020-05-26 17:45:51

标签: android android-studio android-layout material-design

我一直在研究需要FAB的Android应用。当我尝试添加FAB时,它显示为矩形而不是圆形。默认情况下如何获取圆形。

我在gradle中添加了implementation 'com.google.android.material:material:1.1.0依赖项

rectangular floating action button
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>

1 个答案:

答案 0 :(得分:-1)

第一:重新启动Andriod工作室 第二:制作干净的项目