So, i have drawable from https://github.com/facebook/shimmer-android
val shimmer = ColorHighlightBuilder()
.setBaseColor(ContextCompat.getColor(context, R.color.skeleton_mask))
.setBaseAlpha(SHIMMERING_BASE_ALPHA)
.setHighlightAlpha(SHIMMERING_HIGHLIGHT_ALPHA)
.setHighlightColor(ContextCompat.getColor(context, R.color.skeleton_shimmer))
.setDuration(SHIMMERING_DURATION)
.setDirection(Shimmer.Direction.LEFT_TO_RIGHT)
.setAutoStart(true)
.build()
val shimmerDrawable = ShimmerDrawable()
shimmerDrawable.setShimmer(shimmer)
Problem: this drawable has Rect shape, which is being shimmered.
But i want it to be Rect with rounded corners. Is there any solutions, except contributing to library and modifying ShimmerDrawable ? Maybe some wrapping into another drawable, idk
This library has issue about rounded corners https://github.com/facebook/shimmer-android/issues/84 but only solution available is wrapping view holding this drawable with CardView, i do not want this
Well looking at the source code of ShimmerDrawable.java, it's not that hard to implement what you want. There are several things that needs to be changed slightly.
And that is it. But you probably want to modify it a little bit more for your own convenience. If so, ignore the above code and follow the following code.
Later, you can create a
ShimmerDrawable
with:And to be portable across different screen densities, you might also want to convert the values of
xRadius
andyRadius
before creating theShimmerDrawable
.