Skip to content

Latest commit

 

History

History
90 lines (69 loc) · 2.35 KB

README.md

File metadata and controls

90 lines (69 loc) · 2.35 KB

Avatar-Generator-Android

A Material like circular avatar library for android. Generate first letter avatar Image like Google Contacts and random background.

Demo Apk

Preview

Gradle Dependency

-Add it in your root build.gradle at the end of repositories:

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

-Add the dependency

dependencies {
	        implementation 'com.github.RevelationCoding:Android-Avatar:Tag'
	}

Usage

-Xml

<!--when random color is set true backgroundColor will be not set-->
<com.RevelationCoding.mylibrary.AndroidAvatar
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_centerHorizontal="true"
           android:layout_centerVertical="true"
           app:text="Name"
           app:backgroundWidth="400"
           app:backgroundHeight="400"
           app:textSize="56"
           app:imageSrc="@drawable/jordan"
           app:randomColor="true"
           app:backgroundColor="@color/dark"
           app:textColor="@color/white" />

-Java

AndroidAvatarLib androidAvatarLib;
androidAvatarLib = findViewById(R.id.avatarBack_random);

//to set random color on click
androidAvatarLib.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               androidAvatarLib.setRandomColor();
           }
       });

-AndroidAvatarLib Available Methods

setChar(char c);
setTextSize(int size);
setRandomColor();
setBackColor(int color);
setTextColor(int color);
setBackgroundHeight(int height);
setBackgroundWidth(int width);
setText(String string);
setImageSrc(Drawable imageFile, int imageError, ImageView.ScaleType scaleType);
setImageUrl(String imageUrl, int imageError, ImageView.ScaleType scaleType);

Contribution

Feel free to submit issues and enhancement requests. I'm very new to coding and git so I'm absolutely open to feedback and sugggestion. :)