All Projects → TangoAgency → Avatar View

TangoAgency / Avatar View

Licence: mit
Avatar ImageView with user's name first letter Drawable placeholder

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Avatar View

andColorPicker
Color picker library for Android
Stars: ✭ 233 (-24.6%)
Mutual labels:  android-ui, android-view
Polygondrawingutil
A compact Android utility for constructing and drawing rounded regular polygons.
Stars: ✭ 805 (+160.52%)
Mutual labels:  android-view, android-ui
Proswipebutton
A swipe button for Android with a circular progress bar for async operations
Stars: ✭ 319 (+3.24%)
Mutual labels:  android-view, android-ui
Smiley Rating
A custom android Rating view with Interactive Smiles 😄
Stars: ✭ 103 (-66.67%)
Mutual labels:  android-view, android-ui
Krumbsview
🍞 The ultimate breadcrumbs view for Android!
Stars: ✭ 170 (-44.98%)
Mutual labels:  android-view, android-ui
Anychart Android
AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
Stars: ✭ 1,762 (+470.23%)
Mutual labels:  android-view, android-ui
Xcdanmuview
Android弹幕效果View-支持左右两个方向
Stars: ✭ 28 (-90.94%)
Mutual labels:  android-view, android-ui
Android library
android_library
Stars: ✭ 170 (-44.98%)
Mutual labels:  android-view, android-ui
SignatureView
【Android View】:好用的Android电子签名板,能保存所签名的图片
Stars: ✭ 89 (-71.2%)
Mutual labels:  android-ui, android-view
Xtimer Flutter App
Flutter timer app
Stars: ✭ 255 (-17.48%)
Mutual labels:  android-ui
Touchdemo
Custom touch handling in Android
Stars: ✭ 273 (-11.65%)
Mutual labels:  android-ui
RecyclerELE
Android Library for easy addition of Empty, Loading and Error views in a RecyclerView
Stars: ✭ 27 (-91.26%)
Mutual labels:  android-ui
Handygridview
HandyGridView是一个高仿支付宝,网易新闻的高性能的标签可拖动排序的GridView。
Stars: ✭ 255 (-17.48%)
Mutual labels:  android-ui
Cornersheet
Behavior to expand view from corner
Stars: ✭ 274 (-11.33%)
Mutual labels:  android-ui
android-SpringAnimator
A framer.js DHO and RK4 spring animation port for Android.
Stars: ✭ 39 (-87.38%)
Mutual labels:  android-ui
Spedittool
An efficient and scalable library for inputing and displaying gif or @mention on graph-text mixed TextView/EditText
Stars: ✭ 292 (-5.5%)
Mutual labels:  android-ui
Coffeegram
Android app using Jetpack Compose together with StateFlow and MVI
Stars: ✭ 155 (-49.84%)
Mutual labels:  android-ui
JetComposer
Collection of UIs and Animations built with Jetpack Compose for Android
Stars: ✭ 294 (-4.85%)
Mutual labels:  android-ui
Skeleton
A library provides an easy way to show skeleton loading view like Facebook and Alipay
Stars: ✭ 3,368 (+989.97%)
Mutual labels:  android-ui
Bottomdrawer
BottomSheet with animations
Stars: ✭ 291 (-5.83%)
Mutual labels:  android-ui

Avatar View

Download Build Status Android Arsenal Avatar View

Avatar View library was implemented based on Matt Precious's Don’t Fear the Canvas lecture. I decided to create this library in order to achieve an ImageView which can smoothly display user's profile image or his username/name initial letter (in the case when the image was not provided).

Please take a look at the examples below:

Simple library presentation ExampleActivity & BindingsExample
FirstExample SecondExample

Usage

This library can be used in two ways: using standard Android methods and using Android Data Binding.

###Standard:

Step 1

Add gradle dependency:

dependencies {
    compile 'agency.tango.android:avatar-view:{latest_release}'

    //if you want to use Picasso for loading images
    compile 'agency.tango.android:avatar-view-picasso:{latest_release}'

    //if you want to use Glide for loading images
    compile 'agency.tango.android:avatar-view-glide:{latest_release}'
}

Step 2

Add to your xml layout file:

<agency.tango.android.avatarview.views.AvatarView
    android:layout_width="100dp"
    android:layout_height="100dp"
    app:av_border_color="@android:color/white"
    app:av_border_width="4dp"
    app:av_text_size_percentage="35" />

Step 3

Add to your activity:

    AvatarView avatarView;
    IImageLoader imageLoader;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        avatarView = (AvatarView) findViewById(R.id.avatar_view_example);

        imageLoader = new PicassoLoader();
        imageLoader.loadImage(avatarView, "http:/example.com/user/someUserAvatar.png", "User Name");
    }

If you want to use a different library than Picasso for loading images you have to create a loader which extends ImageLoaderBase class. Basically, you have to override one method. Take a look how I have done it in PicassoLoader available in the avatar-view-picasso module.

ImageLoaderBase has two constructors: one with no parameters and second one where you can pass String placeholder in order to change the default "-". You can also set it directly in AvatarPlaceholder constructor. More info about AvatarPlaceholder here.

###Data Binding:

Step 1

Add gradle dependency:

dependencies {
    compile 'agency.tango.android:avatar-view:{latest_release}'
    compile 'agency.tango.android:avatar-view-bindings:{latest_release}'

    //if you want to use Picasso for loading images
    compile 'agency.tango.android:avatar-view-picasso:{latest_release}'

    //if you want to use Glide for loading images
    compile 'agency.tango.android:avatar-view-glide:{latest_release}'
}

Step 2

I will show how to edit your xml file based on User class. Let's see:

<data>
    <variable
        name="user"
        type="User" />
</data>

<agency.tango.android.avatarview.views.AvatarView
    android:layout_width="100dp"
    android:layout_height="100dp"
    bind:av_border_color="@android:color/white"
    bind:av_border_width="6dp"
    bind:av_text_size_percentage="40"
    bind:avatarUrl="@{user.avatarUrl}"
    bind:name="@{user.name}" />

Step 3

Add to your activity:

private ExampleActivityBinding binding;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = DataBindingUtil.setContentView(this, R.layout.example_activity, new ExampleDataComponent());
    binding.setUser(new User("User Name", "http:/example.com/user/someUserAvatar.png"));
}

private static class ExampleDataComponent implements DataBindingComponent {
    public AvatarViewBindings getAvatarViewBindings() {
        return new AvatarViewBindings(new PicassoLoader());
    }
}

Take a look at AvatarViewBindings class where BindingsAdapter is configured (bind:avatarUrl and bind:name for usage in XML). In order to correctly use AvatarViewBindings you have to create class extending DataBindingComponent and pass it as a third parameter in DataBindingUtil.setContentView() method. This is obligatory because AvatarViewBindings takes an IImageLoader parameter in it's constructor. You can find more information about this topic in Deep dive into Android Data Binding talk.

I have explained PicassoLoader issue in step 3 in Standard Method part.

####AvatarPlaceholder

AvatarPlaceholder is a Drawable which is set as a AvatarView background when the image hasn't been loaded yet. It is a letter on a one-color background (just like in ex. Google, Youtube avatars). Default placeholder String (displayed when the username is null or empty) is "-". TextSizePercentage value sets how big part of the view is taken by the text. Default textSizePercentage is 33. You can change those values by passing another ones in AvatarPlaceholder constructor or not directly by using IImageLoader class methods/constructors.

####Additional information

  • Avatar background color is calculated using hashCode() method called on a given name String.
  • Default border width is 2dp and default border color is white.
  • Placeholder letters are currently always white (in future user will be able to choose a different color).
  • It is recommended to set your default placeholder String as short as possible (the best would be one letter).

Getting Help

To report a specific problem or feature request, open a new issue on Github.

Company

Facebook     Twitter     LinkedIn

Here you can see open source work developed by Tango Agency.

Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.

You can contact us via [email protected]. Thanks in advance.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].