BottomAppBar
组件。 <com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_gravity="bottom"
app:fabCradleMargin="8dp"
app:fabCradleRoundedCornerRadius="8dp"
app:fabCradleVerticalOffset="0dp"
... />
<com.google.android.material.floatingactionbutton.FloatingActionButton
app:layout_anchor="@id/bar"
../>
你需要使用以下属性:
fabCradleMargin
属性。它可以增加或减小 FloatingActionButton
和 BottomAppBar
之间的距离。fabCradleRoundedCornerRadius
属性。它指定了切口周围的圆角程度。旧版支持库
使用支持库 28.0.0,设计库中包含BottomAppBar
。
您可以使用
<android.support.design.bottomappbar.BottomAppBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:backgroundTint="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
您可以使用以下属性自定义组件:
app:fabAlignmentMode
:声明已附加到底部应用栏的FAB的位置。这可以是end
或center
app:fabCradleVerticalOffset
:声明要用于附加fab的垂直偏移量。默认情况下,这是0dp。
app:backgroundTint
:用于将色调应用于视图的背景。
此外,您还可以通过在要附加的FAB组件上使用app:layout_anchor
,并使用底部应用栏的ID来附加fab。
应用栏:底部
底部应用栏提供访问底部导航抽屉和最多四个操作,包括浮动操作按钮。
底部应用栏可以包含适用于当前屏幕上下文的操作。它们在极左侧包含导航菜单控件和浮动操作按钮(如果有一个)。如果包含在底部应用栏中,则溢出菜单控件放置在其他操作的末尾。
信息 输入链接说明
<android.support.design.widget.FloatingActionButton
android:id="@+id/FloatingActionButtonAddEmp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
app:srcCompat="@drawable/ic_save_black_24px"
app:layout_anchor="@+id/bottom_appbar"/>
<android.support.design.bottomappbar.BottomAppBar
android:id="@+id/bottom_appbar"
android:elevation="4dp"
style="@style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:fabAttached="true"
app:backgroundTint="@color/io15_grey"/>