my floating action button shows up too low, even though it looks just fine in the Android Studio preview (see below).
FB is placed in root under CoordinatorLayout and set to show at the bottom end using android:layout_gravity.
This Layout is used in Fragment (extends Fragment) with Tabbed Activity using ViewPager. Android X.
Thanks
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmentTableCoordinator"
tools:context=".fragment.FragmentTable">
<!-- CoordinatorLayout for Floating Button -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/fragmentTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorBackgroundCards">
<!-- Total Card -->
<androidx.cardview.widget.CardView
android:id="@+id/card_viewNew"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="fill_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/Total_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:layout_constraintGuide_percent="0.5" />
<!-- some textViews here -->
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<!-- RecyclerView with months -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/Total_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:scrollbars="vertical"
android:visibility="visible"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/card_viewNew" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Floating button -->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floating_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:contentDescription="TODO"
app:srcCompat="@android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
question from:
https://stackoverflow.com/questions/66062107/floating-button-showed-too-low-placed-in-coordinatorlayout-with-androidlayout 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…