因此,经过一周的深入研究,我终于想出了一个绕过这个问题的解决方案!
我最终移除了
Toolbar
和
FrameLayout
从…起
HomeActivity
,而是创建了一个新的布局资源文件并将其命名为“
app_bar.xml
,其中包含以下代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".core.MainActivity">
<FrameLayout
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elevation="0dp"
android:stateListAnimator="@null">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.AppBarLayout>
</RelativeLayout>
然后,我将
app_bar
在
家庭活动
使用布局
include
标记(
家庭活动
还包含
NavigationView
嵌套在
DrawerLayout
)。
我希望这能帮助任何遇到这个问题的人。如果您还有任何疑问,请立即询问!