Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

When using inside cardView with rounded corners, corners are CLEARED #116

Open
qoswa opened this issue Jun 10, 2021 · 1 comment
Open

When using inside cardView with rounded corners, corners are CLEARED #116

qoswa opened this issue Jun 10, 2021 · 1 comment

Comments

@qoswa
Copy link

qoswa commented Jun 10, 2021

Environment: Android emulator, Nexus 5 Api 25

Layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_margin="20dp">

    <androidx.cardview.widget.CardView
        android:id="@+id/image_card"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:elevation="6dp"
        app:cardCornerRadius="14dp">

        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            tools:ignore="ContentDescription" />

    </androidx.cardview.widget.CardView>

</FrameLayout>

Activity:

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val imageView = findViewById<ImageView>(R.id.image)
        val shimmer = Shimmer.ColorHighlightBuilder()
            .setBaseColor(ContextCompat.getColor(this, R.color.skeleton_mask))
            .setBaseAlpha(1f)
            .setHighlightAlpha(1f)
            .setHighlightColor(ContextCompat.getColor(this, R.color.skeleton_shimmer))
            .setDuration(2000)
            .setDirection(Shimmer.Direction.LEFT_TO_RIGHT)
            .setAutoStart(true)
            .build()
        val shimmerDrawable = ShimmerDrawable()
        shimmerDrawable.setShimmer(shimmer)
        imageView.setImageDrawable(shimmerDrawable)
    }

}

Results in:
newimage

As i can see the reason is that CardView uses RoundedCornerDrawable underneath and when we place our ShimmerDrawable over it, PorterDuff.Mode.SRC_IN clears corner pixels (and because of it they are black)

@shreelakshmijoshi
Copy link

Hi @qoswa !
I am a new open source contributor and would like to solve this issue, could you help me understand the issue better by providing some extra references ?
Is this is issue open to contribute ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants