我创建了一个名为ToolBar的控件,并将其设置为我的ActionBar,同时让它透明。现在的问题是,我希望它覆盖在其他内容上方,但现在它还像普通的ActionBar一样工作,我的LinearLayout在它下面停止。如何让我的ToolBar覆盖整个布局并填充整个屏幕?
原始ActionBar的样式仅为:
原始ActionBar的样式仅为:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowActionBarOverlay">true</item>
</style>
我的工具栏
:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:minHeight="?attr/actionBarSize"
android:background="@android:color/transparent"/>
以及我的 ToolBar
声明:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundResource(Color.TRANSPARENT);
setSupportActionBar(toolbar);
我觉得我错过了一些非常简单的东西,但是在搜索之后我找不到我要寻找的解决方案。任何帮助都将不胜感激!
编辑: 这是我的完整XML主布局:
<FrameLayout 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"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main layout -->
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Nav drawer -->
<fragment
android:id="@+id/fragment_drawer"
android:name="rsay.android.scrollbanner.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="left|start" />
</android.support.v4.widget.DrawerLayout>
DrawerLayout
而不是LinearLayout
,当我从左边滑动时导航抽屉是存在的,但是ToolBar
不可见,我猜它在其他布局后面,有没有属性需要指定将其置于最前面? - Ryan SaylesCoordinatorLayout
上方的Toolbar
情况下运作正常。 - Eido95