微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在CollapsingToolbarLayout中具有形状和透明背景的RecyclerView

如何解决在CollapsingToolbarLayout中具有形状和透明背景的RecyclerView

我有一个带有appbar_scrolling_view_behavior的recyclerview。我想将recyclerView的背景作为形状,但无法使形状背景透明:

enter image description here

我已将片段中的顶部布局设置为透明,并使仅包含活动的布局具有非透明背景,但是形状背景始终是包含活动布局中设置的任何颜色。

我的recyclerView看起来像这样

enter image description here

    <?xml version="1.0" encoding="utf-8"?>
<layout 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">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:background="@color/sysTransparent"
        android:layoutDirection="ltr"
        tools:context=".fragment.main.MainFragment">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appbar_layout"
            android:layout_width="match_parent"

            android:background="@color/sysTransparent"
            android:layout_height="290dp">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed|enteralways">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:alpha="0.25"
                    android:scaleType="centerCrop"
                    android:src="@drawable/random_things" />


            </com.google.android.material.appbar.CollapsingToolbarLayout>

        </com.google.android.material.appbar.AppBarLayout>


        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_items"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background_top_cut"
            android:clipToPadding="false"
            android:paddingBottom="100dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。