Android AHBottomNavigation始终位于浮动操作按钮的前面

Android AHBottomNavigation始终位于浮动操作按钮的前面,android,android-layout,Android,Android Layout,我试图创建一个布局,在底部导航菜单的顶部有一个FAB,但菜单始终位于按钮上方:( My layout.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.c

我试图创建一个布局,在底部导航菜单的顶部有一个FAB,但菜单始终位于按钮上方:(

My layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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"
    android:id="@+id/container"
    tools:context="com.example.mytest.money.MainActivity">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        android:layout_height="110dp"
        android:padding="15dp"
        card_view:cardElevation="2dp"
        card_view:cardCornerRadius="4dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Test" />

    </android.support.v7.widget.CardView>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true"
        android:foreground="@color/colorBackground">
    </ScrollView>

    <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:selectedBackgroundVisible="false"
        android:layout_gravity="bottom" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/create_gain_expense"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:layout_margin="15dp"
        android:layout_above="@id/bottom_navigation"
        android:src="@drawable/ic_add_white_24dp"
        app:fabSize="normal" />

</android.support.design.widget.CoordinatorLayout>

我得到的是:


我能做些什么来改变这个?:D

我想问题是,
AHBottomNavigation
FloatingActionButton
具有更高的
高程,这就是为什么它显示在
FloatingActionButton
上方

FloatingActionButton
具有默认的
6dp
高程,
AHBottomNavigation
的默认
高程为
8dp
(来自
AHBottomNavigation

尝试将更高的
高程设置为
FloatingActionButton

<android.support.design.widget.FloatingActionButton
    android:id="@+id/create_gain_expense"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center"
    android:layout_margin="15dp"
    android:layout_above="@id/bottom_navigation"
    android:src="@drawable/ic_add_white_24dp"
    app:fabSize="normal"
    app:elevation="12dp"
    app:borderWidth="0dp" />


希望这会有所帮助~

我想问题是,
AHBottomNavigation
FloatingActionButton
高程更高,这就是为什么它显示在
FloatingActionButton
上方

FloatingActionButton
具有默认的
6dp
高程,
AHBottomNavigation
的默认
高程为
8dp
(来自
AHBottomNavigation

尝试将更高的
高程设置为
FloatingActionButton

<android.support.design.widget.FloatingActionButton
    android:id="@+id/create_gain_expense"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center"
    android:layout_margin="15dp"
    android:layout_above="@id/bottom_navigation"
    android:src="@drawable/ic_add_white_24dp"
    app:fabSize="normal"
    app:elevation="12dp"
    app:borderWidth="0dp" />

希望这会有所帮助~

尝试以下代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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"
    android:id="@+id/container">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        android:layout_height="110dp"
        android:padding="15dp"
        card_view:cardElevation="2dp"
        card_view:cardCornerRadius="4dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Test" />

    </android.support.v7.widget.CardView>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true"
        android:foreground="@color/white">
    </ScrollView>

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_weight="1"
        android:layout_gravity="bottom"
        android:background="@color/green"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/white"
        android:id="@+id/bottomnav"
        app:menu="@menu/main">


    </android.support.design.widget.BottomNavigationView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/create_gain_expense"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:layout_margin="15dp"
        android:layout_above="@id/bottom_navigation"
        android:src="@drawable/ic_add_black_24dp"
        app:fabSize="normal"
        app:elevation="12dp"
        app:borderWidth="0dp" />

</android.support.design.widget.CoordinatorLayout>

您可以用自己的导航栏替换此底部导航栏。

尝试以下代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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"
    android:id="@+id/container">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        android:layout_height="110dp"
        android:padding="15dp"
        card_view:cardElevation="2dp"
        card_view:cardCornerRadius="4dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Test" />

    </android.support.v7.widget.CardView>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true"
        android:foreground="@color/white">
    </ScrollView>

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_weight="1"
        android:layout_gravity="bottom"
        android:background="@color/green"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/white"
        android:id="@+id/bottomnav"
        app:menu="@menu/main">


    </android.support.design.widget.BottomNavigationView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/create_gain_expense"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:layout_margin="15dp"
        android:layout_above="@id/bottom_navigation"
        android:src="@drawable/ic_add_black_24dp"
        app:fabSize="normal"
        app:elevation="12dp"
        app:borderWidth="0dp" />

</android.support.design.widget.CoordinatorLayout>

您可以用自己的导航栏替换此底部导航栏。