Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 始终将浮动操作按钮置于顶部_Android_Android Layout_Android Fragments_Android Linearlayout_Floating Action Button - Fatal编程技术网

Android 始终将浮动操作按钮置于顶部

Android 始终将浮动操作按钮置于顶部,android,android-layout,android-fragments,android-linearlayout,floating-action-button,Android,Android Layout,Android Fragments,Android Linearlayout,Floating Action Button,我有Mainactivity、一个片段和BlogRecycleadapter来用博客文章填充片段 在Mainactivity中,我有浮动操作按钮。但当我运行应用程序时,它隐藏在BlogRecycledAdapter项下 如何使浮动操作按钮始终位于顶部 我的主要活动布局是 您可以增加高程,直到它在底部导航上可见为止。 给出高于8dp的高度并尝试 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/androi

我有Mainactivity、一个片段和BlogRecycleadapter来用博客文章填充片段

在Mainactivity中,我有浮动操作按钮。但当我运行应用程序时,它隐藏在BlogRecycledAdapter项下

如何使浮动操作按钮始终位于顶部

我的主要活动布局是


您可以增加高程,直到它在底部导航上可见为止。 给出高于8dp的高度并尝试

<RelativeLayout 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.support.v7.widget.Toolbar
    android:id="@+id/main_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:background="@color/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Light" />


<android.support.design.widget.BottomNavigationView
    android:id="@+id/mainBottomNav"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:menu="@menu/bottom_bar_menu" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/add_post_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/mainBottomNav"
    android:layout_alignParentRight="true"
    android:layout_marginRight="20dp"
    android:clickable="true"
    android:focusable="true"
    android:visibility="visible"
    app:elevation="10dp" />


<FrameLayout
    android:id="@+id/main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/mainBottomNav"
    android:layout_below="@+id/main_toolbar">

</FrameLayout>

</RelativeLayout>


只需将您的片段加载到主容器中。。希望这能起作用

请尝试以下活动布局:


像这样尝试(反转FramLayout和FloatingAction按钮的位置):



尝试添加LayoutAppy以提供帮助。:)现在操作工具栏不可见,如何将其取回?将layout_放在FrameLayout标记中的=“@id/main_Toolbar”下方,并使用上面的layout_=“+@id/mainbotmnav”以避免底部菜单隐藏
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    tools:context=".Main2Activity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/main_toolbar"
        app:titleTextAppearance="@style/Toolbar.TitleText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.Toolbar>



    <android.support.design.widget.BottomNavigationView
        android:id="@+id/mainBottomNav"
        android:background="@color/colorblog"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:menu="@menu/bottom_menu"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />


<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></FrameLayout>
    <FrameLayout
        android:id="@+id/main_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/mainBottomNav"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/main_toolbar"
        app:layout_constraintVertical_bias="1.0">

    </FrameLayout>


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/add_post_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:clickable="true"
        android:layout_gravity="bottom|end"
        android:focusable="true"
        android:visibility="visible"
        app:elevation="6dp"
        app:layout_constraintBottom_toTopOf="@+id/mainBottomNav"
        app:layout_constraintEnd_toEndOf="parent"
        app:srcCompat="@mipmap/action_add" />


</android.support.constraint.ConstraintLayout>