DeweyAvatar

class DeweyAvatar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FrameLayout

A custom view for displaying an avatar image with a state badge.

The avatar image can be set using setImageBitmap, setImageResource, or setImageDrawable. Before showing the image, the avatar will display a placeholder image based on the Placeholder.Type set using setImagePlaceholder. The avatar can also display a state badge using setStateBadge.

The size of the avatar is limited to a set of predefined Sizes, which can be set using setSize. Therefore, WRAP_CONTENT should be used for the height and width of the view.

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

For adding a placeholder image to the avatar view.

Link copied to clipboard
annotation class Size

The size of the avatar view. Width and height are set to the same value.

Link copied to clipboard

The state badge to display at the bottom right of the avatar.

Link copied to clipboard

Can be used to force the UI mode of the avatar view.

Functions

Link copied to clipboard

Get the image view of the avatar. For customization purposes.

Link copied to clipboard
fun setImageBitmap(bitmap: Bitmap)

Set the image of the avatar using a bitmap.

Link copied to clipboard
fun setImageDrawable(drawable: Drawable?)

Set the image of the avatar using a drawable.

Link copied to clipboard

Set the placeholder image to display before the avatar image is set.

Link copied to clipboard

Set the image of the avatar using a resource ID.

Link copied to clipboard
fun setSize(size: Int)

Set the size of the avatar view.

Link copied to clipboard

Set the state badge to display at the bottom right of the avatar.

Link copied to clipboard

Set the UI mode of the avatar view. Can be used to force the UI mode to light or dark.