Skip to content

Instantly share code, notes, and snippets.

@BracketCove
Created October 21, 2022 16:17
Show Gist options
  • Save BracketCove/013a999ed211d8a6281437799d5dfb8b to your computer and use it in GitHub Desktop.
Save BracketCove/013a999ed211d8a6281437799d5dfb8b to your computer and use it in GitHub Desktop.
Easy animated loading spinner with Glide (or whatever image loading library)
//use this in your Recyclerview or whereever for asynchornous image loading
Glide.with(holder.itemView.context)
.load(avatarUrl)
.centerCrop()
.placeholder(
CircularProgressDrawable(holder.itemView.context).apply {
setColorSchemeColors(
ContextCompat.getColor(holder.itemView.context, R.color.colorPrimary)
)
strokeWidth = 2f
centerRadius = 10f
start()
}
)
.into(holder.avatar)
// Add this to build.gradle (app/sub-project level) and adjust version accordingly:
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment