ColoredShadowImageView
ColoredShadowImageView allows you to create a beautiful shadow around the image based on corresponding area colors.


Download sample apk
The current minSDK version is API level 16.
Download :arrow_down:
Gradle:
implementation 'com.github.armcha:ColoredShadowImageView:1.1.0'
Setup and usage
- You also need to add RenderScript to your app module. Add these lines to the defaultConfig block of your build.gradle.
renderscriptTargetApi YOUR_TARGET_SDK_VERSION
renderscriptSupportModeEnabled true
- Static image
<io.github.armcha.coloredshadow.ShadowImageView
android:id="@+id/shadowImage"
android:layout_width="300dp"
android:layout_height="400dp"
android:src="@drawable/android"/>
Or
findViewById<ShadowImageView>(R.id.shadowImage).apply {
setImageResource(R.drawable.android)
}
- If you are using Glide, use it in this way. Glide transformations are also supported. Now we have some limitations for Glide transitions.
//shadowView.radiusOffset = 0.4f
//shadowView.shadowColor = ContextCompat.getColor(context,R.color.green)
GlideApp.with(itemView.context)
.load(item.imageUrl)
.placeholder(R.drawable.place_holder)
.error(R.drawable.place_holder)
//.transform(CircleCrop())
.into(object : ViewTarget<ImageView, Drawable>(shadowView) {
override fun onLoadStarted(placeholder: Drawable?) {
super.onLoadStarted(placeholder)
shadowView.setImageDrawable(placeholder, withShadow = false)
}
override fun onLoadCleared(placeholder: Drawable?) {
super.onLoadCleared(placeholder)
shadowView.setImageDrawable(placeholder, withShadow = false)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
shadowView.setImageDrawable(errorDrawable, withShadow = false)
}
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
shadowView.setImageDrawable(resource)
}
})