2015-04-27 58 views
0

我想让我的工具栏/操作栏透明。我可以看到一个透明的工具栏,但隐藏在片段加载的小部件后面。该小部件是图像的轮播。所以当图像翻转时,我可以看到它下面的工具栏。这是我的应用主题。Android AppCompat覆盖工具栏隐藏在部件后

<style name="AppTheme" parent="@style/Theme.AppCompat.Light"> 
    <item name="colorPrimary">#19b333</item> 
    <!-- ActionBar Theming --> 
    <item name="android:actionBarStyle">@style/MyActionBar</item> 

    <!-- Support library compatibility --> 
    <item name="actionBarStyle">@style/MyActionBar</item> 
</style> 

这是我的ActionBar主题。

<style name="MyActionBar" parent="ThemeOverlay.AppCompat.Light"> 
    <item name="android:background">@color/color_primary</item> 
    <item name="android:windowActionBarOverlay">true</item> 

    <!-- Support library compatibility --> 
    <item name="background">@color/color_primary</item> 
    <item name="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" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:minHeight="?attr/actionBarSize"/> 

这是我activity_drawer布局

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
    tools:context=".activity.DrawerActivity"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <include layout="@layout/view_toolbar"/> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </RelativeLayout> 

    <fragment 
     android:name="com.example.fragment.SidebarFragment" 
     android:id="@+id/sidebar" 
     android:layout_width="@dimen/sidebar_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     tools:layout="@layout/fragment_sidebar" /> 

</android.support.v4.widget.DrawerLayout> 

回答

2

把工具栏内容容器后。

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <include layout="@layout/view_toolbar"/> 

</RelativeLayout>