Code Monkey home page Code Monkey logo

avatarimageview's Introduction

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 (Two Step)

Step 1

Add the dependency in project level gradle file.

allprojects {
		repositories {
			maven { url 'https://jitpack.io' }
		     }
	   }

Step 2

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

dependencies {
    implementation 'com.github.indra58:AvatarImageview:Tag'
}

Getting Started (Two Steps)

Prerequisites

  1. Android API 14+ is required as the minSdkVersion in your build.gradle.
  2. Add permissions in your AndroidManifest.xml to load image.
<!-- 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. app:aiv_radius="12" (integer)
    2. app:aiv_margin="5" (integer)
    3. app:aiv_shape="normal" or "round" or "curved" (String)
    4. app:aiv_text_size="18" (float)
    5. app:aiv_font_family="@font/your_font_name" (reference)
  1. Round Image

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

Then, in your activity:

AvatarImageView avatarImageView = findViewById(R.id.imageView);

UserAvatar userAvatar = new UserAvatar("https://yourimageurl or file absolute path or file itself", "Avatar Name");

avatarImageView.setAvatar(userAvatar);
  1. Add radius to your image

<imageview.avatar.com.avatarimageview.AvatarImageView
        android:id="@+id/imageView"
        android:layout_width="72dp"
        android:layout_height="72dp"
        app:aiv_radius="20"
        app:aiv_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");

Additional properties supported:

<imageview.avatar.com.avatarimageview.AvatarImageView
        android:id="@+id/imageView"
        android:layout_width="72dp"
        android:layout_height="72dp"
        app:aiv_text_size="26"
        app:aiv_font_family="@font/your_font_name" />

Thanks

DemoApp

DemoApp Coming Soon!!!

avatarimageview's People

Contributors

indra58 avatar nabsshrestha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.