android - 我的浮动操作按钮未正确显示...?
问题描述
我正在使用带有View Pager的TAB LAYOUT和带有用于底部导航的浮动操作按钮的BOTTOM APP BAR,但我认为我的浮动操作按钮显示在视图寻呼机下,所以它看起来像是从上面切开的......请帮助我解决这个问题
这是我的 XML 代码....
<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"
android:background="@drawable/ic_main_bg"
tools:context=".home.HomeActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bottom_navigation_bg"
app:fabCradleRoundedCornerRadius="0dp"
app:backgroundTint="@color/color_primary"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="@color/color_primary"
app:srcCompat="@drawable/ic_plus"
app:layout_anchor="@id/bottomAppBar"
android:contentDescription="@string/add_item_to_this_destination" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_primary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorColor="@color/color_secondary"
app:tabSelectedTextColor="@color/color_secondary"
app:tabTextColor="@color/color_secondary" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager_2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/coordinator_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tab_layout">
</androidx.viewpager2.widget.ViewPager2>
</androidx.constraintlayout.widget.ConstraintLayout>
这就是它的样子
解决方案
问题是因为 CoordinatorLayout
解决方案 1:添加
android:clipToPadding="false"
android:clipChildren="false"
在协调器布局中
解决方案2:将CoordinatorLayout设为父布局,并将所有子布局放入其中。
解决方案3:
在 view_pager_2 添加
android:layout_marginBottom="?actionBarSize"
解决方案 4:将此生产线添加到您的工厂
android:elevation="10dp"
推荐阅读
- cytoscape.js - 如何将 Cytoscape 圆形节点分成几块
- python - 是否有类似于 matlab 的 python 语法来选择行和列?
- mongodb - 从聚合查询中的周整数获取isodate | 从 1 到 2019 年 12 月 30 日,从 2 到 2020 年 6 月 1 日
- ios - IOS:使用重复触发的通知仅在设备解锁时显示?
- angular - 如何从 Angular 8 在 AWS S3 中上传文件
- powerbi - DAX:同一张表上的嵌套总和
- firebase - 具有欧洲自定义域名的firebase功能
- c# - 这两个简单的 Async 和 Await 实现之间的输出差异
- .net - .NET Core 在 AzuerAD 身份验证后添加声明
- css - 尽管设置了最小宽度和高度,但溢出在网格列中不起作用