'CardView's corner radius acts strangely in Google Maps InfoWindow

It looks like that the same XML layout code works differently in InfoWindow and "normal" activity/fragment.

I'm customizing my Google Maps InfoWindow. I've already applied rounded corners to it (I use getInfoWindow()) and now I'd like to make the ImageView have also rounded corners. When InfoWindow opens up, it shows like this Broken InfoWindow It looked strange to me, so I pasted the CardView and ImageView code (aftermentioned) to an activity. This is how it looked like (don't look at the content, it's loaded at runtime) Fine InfoWindow

My code

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="8dp"
    android:background="@drawable/rounded_corners_bg">

    <androidx.cardview.widget.CardView
        android:id="@+id/container"
        android:layout_width="240dp"
        android:layout_height="160dp"
        android:elevation="0dp"
        android:background="@android:color/black"
        app:cardCornerRadius="32dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:cardElevation="0dp"
        app:contentPadding="0dp">

        <ImageView
            android:id="@+id/imageInfoWindow"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            app:srcCompat="@drawable/opactwo_2" />


    </androidx.cardview.widget.CardView>

    <TextView <!-- Doesn't matter -->

    <TextView <!-- Doesn't matter -->

    <TextView <!-- Doesn't matter -->
</androidx.constraintlayout.widget.ConstraintLayout>

I found out that the same code produces different result. My question is why it doesn't work and what should I do to make it work? I don't apply any theming nor modify views at runtime.



Solution 1:[1]

so, I put https://github.com/rishabh876/RoundedImageView this instead of imageView and use Glide for image downloading

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {

                        if (!isFromMemoryCache) {
                            marker.showInfoWindow();
                        }
                        return false;
                    }
                })
                .into(viewHolder.imageView);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doniyor Rakhmanov