android - 如何制作fab center cut android studio
问题描述
一旦我听说如果你不能做某事 15 分钟寻求帮助......我已经尝试了 2 天。
现在我需要你的帮助。
我想在android studio的AppBar底部制作fab center
屏幕 2 中的代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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=".ActionMenu">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primaryDarkColor"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="@+id/include"
layout="@layout/content_action_menu" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar2"
style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryDarkColor"
app:fabAttached="true"
android:gravity="bottom"
app:elevation="8dp"
app:fabAlignmentMode="center"
app:layout_anchor="@+id/include"
app:layout_anchorGravity="bottom|center" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:elevation="8dp"
app:layout_anchor="@+id/bottomAppBar2"
app:layout_anchorGravity="center|fill_vertical"
app:srcCompat="@android:drawable/ic_menu_add" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
如何在 AppBar 底部制作工厂中心切割?
感谢关注
解决方案
我相信您正在寻找的代码是
app:fabCradleMargin="(x DP here)"
作为浮动操作按钮的属性。
这是我的一个项目的布局,它完全符合您的要求:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_gravity="bottom"
app:backgroundTint="@color/colorPrimary"
app:layout_anchor="@+id/bottomAppBar"
app:layout_anchorGravity="bottom"
app:menu="@menu/app_bar_menu"
app:fabAnimationMode="slide"
app:fabCradleRoundedCornerRadius="8dp"
app:navigationIcon="@drawable/ic_settings"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:clickable="true"
app:backgroundTint="@color/colorAccent"
app:layout_anchor="@id/bottomAppBar"
app:maxImageSize="40dp"
app:srcCompat="@drawable/ic_scan"
app:tint="@color/colorWhite" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
推荐阅读
- uml - 创建类图的最佳方法
- python - 无法在新的 anaconda 安装上更新 spyder=5.1.5
- terraform - 为 fusionauth 导入 terraform 资源时出错
- reactjs - Tiny MCE 中的对话框(即图像、链接等)不接受输入并显示为灰色
- embedded - TlsrComSwireWriter 在 Mac OS 上无法与 Cp2102 一起使用
- apache-kafka - 以编程方式清除 Kafka 主题
- python - 带有 DB2 的 Django 3.2 项目(IBM_DB 驱动程序)
- printing - 打印结果在 databricks 笔记本中被截断
- matlab - MATLAB:绘制 1D 条件分布,其中 k 密度堆叠在 3D 图中
- python - 用列表python中的数字替换哈希