android - CollapsingToolbarLayout中的title在展开时如何设置一个半透明的黑色背景?
黄舟
黄舟 2017-04-18 09:15:24
0
2
653

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>
    
    

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

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
迷茫

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.

伊谢尔伦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template