0

我在一個活動中使用摺疊的工具欄佈局,該應用必須始終顯示在溢出菜單中。問題是,正如你可以在下面看到的(在右上角),這兩個項目都有一個摺疊工具欄的背景,而不是像後退箭頭那樣直接位於封面圖片的頂部。Android摺疊的工具欄溢出菜單有背景

  • 所有使用的繪圖都是無背景的矢量繪圖。

活動XML佈局:

<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" 
    tools:context=".ui.activities.WorkDetailsActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      android:theme="@style/ToolbarTheme" 
      app:collapsedTitleGravity="start" 
      app:contentScrim="@color/colorPrimary" 
      app:expandedTitleMarginEnd="48dp" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleTextAppearance="@style/expandedToolbarTitle" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <RelativeLayout 
       android:id="@+id/toolbar_cover_container" 
       android:layout_width="match_parent" 
       android:layout_height="480dp" 
       android:fitsSystemWindows="true"> 

       <ImageView 
        android:id="@+id/toolbar_cover" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fitsSystemWindows="true" 
        android:scaleType="centerCrop" 
        app:layout_collapseMode="parallax" 
        app:layout_collapseParallaxMultiplier="0.7" /> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/down_dark_gradient" /> 

      </RelativeLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="@android:color/transparent" 
       android:textAlignment="gravity" 
       android:theme="@style/ToolbarTheme" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

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

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/share_fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="16dp" 
     android:clickable="true" 
     android:src="@drawable/ic_share_black" 
     app:layout_anchor="@+id/appbar" 
     app:layout_anchorGravity="bottom|right|end" /> 


</android.support.design.widget.CoordinatorLayout> 

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

擴展布局

enter image description here

倒塌佈局

CollapsedToolbar

回答

0

去除工具欄 android:theme="@style/ToolbarTheme"主題並沒有解決這個問題,將與一個透明背景沒有覆蓋父主題。 <item name="android:background">@color/transparent</item>

相關問題