personalprojectsus / AvatarImageView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AvatarImageView Android

AvatarImageView is android ImageView library for displaying images in multiple styles.

The main goal for developing this library was to make it easy for all programmers to load image in various styles. Our library is:

  • Easy to implement: Just add jCenter dependency for project in your app level gradle file and voila! Half of your work is done. The other half is to implement it in your project. We'll talk about that below :)
  • Easy to understand: Simple and neat code with proper documentation.

Contents

  1. Installation
  2. Getting Started

Installation (One Step)

Add the dependency from jCenter to your app's (not project) build.gradle file.

repositories {
    jcenter()
}

dependencies {
    implementation ''
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}

Getting Started (Two Steps)

Prerequisites

  1. Android API 14+ is required as the minSdkVersion in your build.gradle.
  2. Add permissions (if necessary) to your AndroidManifest.xml
<!-- if you want to load images from the internet -->
<uses-permission android:name="android.permission.INTERNET" /> 

<!-- if you want to load images from a file OR from the internet -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Usage

Add AvatarImageView to your layout

In your activity or fragment, insert AvatarImageView custom view.

AvatarImageView extends FrameLayout, so all of its standard attributes are available to you.

<imageview.avatar.com.avatarimageview.AvatarImageView
       android:id="@+id/imageView"
       android:layout_width="72dp"
       android:layout_height="72dp" />

Additional properties to customize AvatarImageView

  1. Round Image

<imageview.avatar.com.avatarimageview.AvatarImageView
        android:id="@+id/imageView"
        android:layout_width="72dp"
        android:layout_height="72dp"
        app:image_shape="round" />

Then, in your activity:

AvatarImageView avatarImageView = findViewById(R.id.imageView);
avatarImageView.setAvatar("https://yourimageurl or file absolute path", "Avatar Name");
  1. Add radius to your image

<imageview.avatar.com.avatarimageview.AvatarImageView
        android:id="@+id/imageView"
        android:layout_width="72dp"
        android:layout_height="72dp"
        app:image_radius="20"
        app:image_shape="curved" />
        

Then, in your activity:

AvatarImageView avatarImageView = findViewById(R.id.imageView);
avatarImageView.setAvatar("https://yourimageurl or file absolute path", "Avatar Name");

Note: If you want normal image with no roundness or curve in edges. Don't use app provided properties

  1. If you want to show text(nickname) instead of image like in the preview shown below:

Do this:

AvatarImageView avatarImageView = findViewById(R.id.imageView);
avatarImageView.setAvatar("", "Your Avatar Name");

Thanks

DemoApp

DemoApp Coming Soon!!!

About


Languages

Language:Java 100.0%