微光未显示在可塑形图像视图上

问题描述 投票:0回答:1

我在我的应用程序中使用了可变形图像视图。我想加载微光作为占位符,直到图像加载到可成形图像视图中。但微光未加载。在图像加载之前,它仅显示空白图像视图。

<com.google.android.material.imageview.ShapeableImageView
                android:id="@+id/style_img"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:contentDescription="@string/rapturous"
                android:scaleType="centerCrop"
                app:shapeAppearanceOverlay="@style/roundedCornersImageView" />
val shimmer = Shimmer.AlphaHighlightBuilder()
            .setDuration(1800)
            .setBaseAlpha(0.7f)
            .setHighlightAlpha(0.6f)
            .setDirection(Shimmer.Direction.LEFT_TO_RIGHT)
            .setAutoStart(true)
            .build()

        val shimmerDrawable = ShimmerDrawable().apply {
            setShimmer(shimmer)
        }

        Glide.with(context).load(imageUrl).placeholder(shimmerDrawable).into(style_img)

我尝试使用简单的图像视图而不是可成形的图像视图,效果很好。但我希望我的图像视图有圆角。 我正在使用

 implementation 'com.facebook.shimmer:shimmer:0.5.0'
库来闪光

android android-drawable shimmer
1个回答
0
投票

这可能是因为

shapeAppearanceOverlay
影响占位符,另一种选择也是使用普通的
ImageView
,因为你提到它在那里工作,并将这个
ImageView
放在
CardView
MaterialCardView
,所以现在你可以定义圆角,如果你不想定义边框,请将其更改为
0

<com.google.android.material.card.MaterialCardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:strokeWidth="0dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:src="@tools:sample/avatars" />

</com.google.android.material.card.MaterialCardView>
© www.soinside.com 2019 - 2024. All rights reserved.