Generate first letter avatar Image like gmail's contact avatar. It generates an drawable that can be be set to an ImageView.
Installation
Add the Following to your gradle file.
NEW VERSION JITPACK DEPENDENCY
implementation 'com.github.amoskorir:avatarimagegenerator:VERSION'
New Builder pattern
AvatarGenerator.AvatarBuilder(context)
.setLabel(users[position].login)
.setAvatarSize(120)
.setTextSize(30)
.toSquare()
.toCircle()
.setBackgroundColor(Color.RED)
.build()
Supports
Using glide or Picasso you can set the drawable to an imageView as a placeholder.
- Picasso
- Glide
Picasso
Picasso.get()
.load("https://brokenfortest")
.resize(50, 50)
.placeholder(AvatarGenerator.avatarImage(this, 200, AvatarConstants.CIRCLE, "Android"))
.into(imageView2)
Glide
Glide.with(this)
.load("http://brokenfortest")
.placeholder(AvatarGenerator.avatarImage(this, 200, AvatarConstants.CIRCLE, "Kotjav"))
.into(imageView3)
Without any Library
imageView.setImageDrawable(
AvatarGenerator.avatarImage(
this,
200,
AvatarConstants.RECTANGLE,
"Skyways"
)
Shape
- Circle
- Square
.toSquare(),
.toCircle()