简体   繁体   English

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

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

I've been working on a android app which requires FAB.我一直在开发需要 FAB 的 android 应用程序。 When I try to add FAB it appears rectangle instead of circle.当我尝试添加 FAB 时,它显示为矩形而不是圆形。 How to get the circle shape by default.默认情况下如何获取圆形。

I added the implementation 'com.google.android.material:material:1.1.0 dependency in gradle我在 gradle 中添加了implementation 'com.google.android.material:material:1.1.0依赖项

矩形浮动动作按钮
fab.xml 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第一:重启Andriod studio 第二:make clean project

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在android上更改浮动操作按钮(FAB)的形状? - How to change the shape of Floating Action Button (FAB) on android? 如何在 Android 的浮动操作按钮 FAB 中保留可绘制的默认颜色 - How to preserve drawable default color in a Floating Action Button FAB in Android Android - 可移动/可拖动的浮动操作按钮 (FAB) - Android - Movable/Draggable Floating Action Button (FAB) 滚动/粘性FAB浮动操作按钮android - Scrolling / sticky FAB floating action button android Android L - 浮动操作按钮(FAB) - Android L - Floating Action Button (FAB) Android:具有ExpandableListView的浮动操作按钮(fab) - Android: Floating Action Button (fab) with ExpandableListView Android:素材设计的浮动操作按钮(FAB)和移动视图 - Android: material design's Floating Action Button (FAB) and shifting views Android 设计支持库可扩展浮动操作按钮 (FAB) 菜单 - Android Design Support Library expandable Floating Action Button(FAB) menu android:从代码中动态更改FAB(浮动操作按钮)图标 - android: dynamically change FAB(Floating Action Button) icon from code Android:浮动操作按钮以透明背景出现 - Android: Floating Action Button appears with transparent background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM