Avatar

class Avatar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.Default_Avatar_Style, @StyleRes defStyleRes: Int = R.style.BaseAvatar) : View

Avatar.

Since

0.5.4

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.Default_Avatar_Style, @StyleRes defStyleRes: Int = R.style.BaseAvatar)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
annotation class SHAPE

Properties

Link copied to clipboard

The bitmap of the avatar image.

Link copied to clipboard
private val mAvatarDstRectF: RectF
Link copied to clipboard
private val mAvatarPaint: Paint
Link copied to clipboard
private val mAvatarPath: Path
Link copied to clipboard

The avatar size of avatar.

Link copied to clipboard
private val mAvatarSrcRect: Rect
Link copied to clipboard

The color shown when the mAvatar is null.

Link copied to clipboard
private val mBackgroundPaint: Paint
Link copied to clipboard

The corner radius of avatar when the shape is SHAPE_ROUND_CORNER.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
private val mDefaultText: String
Link copied to clipboard
private val mDefaultTextSize: Float
Link copied to clipboard
var mShape: Int

The Shape of avatar. Current support circle and round rectangle.

Link copied to clipboard

The stroke color of avatar.

Link copied to clipboard
private val mStrokePaint: Paint
Link copied to clipboard

The stroke width of avatar.

Link copied to clipboard

The text shown when the mAvatar is null.

Link copied to clipboard

The text color shown when the mAvatar is null.

Link copied to clipboard
private val mTextPaint: Paint
Link copied to clipboard

The text size shown when the mAvatar is null.

Link copied to clipboard

Functions

Link copied to clipboard
private fun getBaseLine(): Float

Get base line

Link copied to clipboard
protected open override fun onDraw(canvas: Canvas)
Link copied to clipboard
protected open override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)
Link copied to clipboard
fun setAvatar(bitmap: Bitmap)

Set avatar by bitmap.

fun setAvatar(file: File)

Set avatar by file.

fun setAvatar(@DrawableRes resId: Int)

Set avatar by resId.

Link copied to clipboard
fun setShape(shape: Int)

Set shape of avatar.