search

Home  >  Q&A  >  body text

android - CollapsingToolbarLayout中的title在展开时如何设置一个半透明的黑色背景?

CollapsingToolbarLayout中的title在展开时如何设置一个半透明的黑色背景?

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/f_a_d_collapsingToolbarLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:collapsedTitleGravity="center"
        app:expandedTitleMargin="15dp"
        app:contentScrim="@color/colorTheme"
        app:statusBarScrim="@android:color/transparent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/function_activity_detail_poster"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/f_a_d_poster"
            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/function_activity_detail_toolbar"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay">
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.CollapsingToolbarLayout>
    
    

想在这里设置一个半透明的黑色背景 该如何实现呢?

黄舟黄舟2771 days ago657

reply all(2)I'll reply

  • 迷茫

    迷茫2017-04-18 09:17:24

    Add a View to the layout and place it at the bottom of CollapsingToolbarLayout. Set the background to a semi-transparent color and adjust the multiplier value so that it slides a short distance and is hidden. This should achieve the effect you want.
    It is worth noting that CollapsingToolbarLayout is essentially a FrameLayout, and you must put the View at the end to display it correctly.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:17:24

    My method is a bit stupid. . . The imageview is replaced by a relativelayout, in which two imageviews are superimposed, with the picture on the lower layer and the mask effect on the upper layer

    reply
    0
  • Cancelreply