Android 工具栏未在片段中显示

Android 工具栏未在片段中显示,android,Android,我创建了一个工具栏,并将其添加到我的main_activity.xml中,如下所示: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activit

我创建了一个
工具栏
,并将其添加到我的main_activity.xml中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_detail"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:background="@color/loginBrown"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="horizontal">


            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center_horizontal"
                android:textColor="#fff"
                android:textSize="16sp" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/navigation"
        android:animateLayoutChanges="true">
    </FrameLayout>
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        app:itemIconTint="@color/nav_item_state_list"
        app:itemTextColor="@color/nav_item_state_list"
        app:menu="@menu/bottom_navigation_items" />
</RelativeLayout>
但是,即使在第一个
片段中没有显示这一点


我使用
fragment.replace()
来显示第一个
片段
,我不知道这是否是错误的

加载片段的框架布局位于工具栏顶部。这就是为什么你看不见它。将
android:layout\u marginTop=“?android:attr/actionBarSize”
添加到framelayout。

加载片段的framelayout位于工具栏顶部。这就是为什么你看不见它。添加
android:layout\u marginTop=“?android:attr/actionBarSize”
到framelayout。

将以下代码添加到framelayout将解决此问题

android:layout_below="@id/toolbar_detail"

希望我能提供帮助。

将以下代码添加到Framelayout将解决此问题

android:layout_below="@id/toolbar_detail"

我希望我能帮上忙。

在android:id=“@+id/frame\u layout”我把layout\u放在下面的地方之后,我必须添加这个,可以吗?在android:id=“@+id/frame\u layout”我把layout\u放在下面的地方,可以吗?