Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Latest commit

 

History

History
64 lines (49 loc) · 2.64 KB

README.MD

File metadata and controls

64 lines (49 loc) · 2.64 KB

Logo

Bintray

Description

AcronymAvatar is a dumb simple library to show avatars with acronyms in your application. Should you like to show user's list in your messenger (yet another one...) or just create an unorthodox user profile? This library is the best choice for you.

UI sample

Getting started

Just include the library into your project as a Gradle dependency:

implementation 'com.redmadrobot:acronym-avatar:2.0'

Then add AvatarView into your XML layout:

    <com.redmadrobot.acronymavatar.AvatarView
        android:id="@+id/user_avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

And pass full username to the setText method:

user_avatar.setText("Captain Nemo")

That's all!

Capabilities

  • Setting text via XML and programmatically
  • Using custom placeholders (Drawables only!)
  • Configuring zoom out for the acronym

Setting text via XML and programmatically

Composing acronyms from text works like this: when you pass a single word through the setText method or through the app:text XML field, the library takes only first two symbols, and makes them an uppercased acronym. In case there are two or more words, the library takes first symbols from first and second words only, and makes them an uppercased acronym. For instance:

  • Captain -> CA
  • Captain Nemo -> CN
  • Nemo, my name forever more -> NM

Using custom placeholders (Drawables only!)

We like our default placeholder very much, but you won't probably want to use it in real-world applications ;) For this case we augmented our library with a custom placeholder feature. You can set it via XML as following:

    <com.redmadrobot.acronymavatar.AvatarView
        android:id="@+id/user_avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        app:placeholder="@drawable/custom_placeholder" />

Configuring zoom out for the acronym

The library is preconfigured to use optimal text zoom factor, but you can set your own value this way:

    <com.redmadrobot.acronymavatar.AvatarView
        android:id="@+id/user_avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        app:zoom_out="5" />