Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.androidsoftcoders:AvatarImageView:2.4'
}
<dependency>
<groupId>com.github.androidsoftcoders</groupId>
<artifactId>AvatarImageView</artifactId>
<version>2.4</version>
</dependency>
libraryDependencies += "com.github.androidsoftcoders" % "AvatarImageView" % "2.4"
:dependencies [[com.github.androidsoftcoders/AvatarImageView "2.4"]]
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:
Add the dependency in project level gradle file.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency from jCenter to your app's (not project) build.gradle
file.
dependencies {
implementation 'com.github.androidsoftcoders:AvatarImageView:1.2'
}
minSdkVersion
in your build.gradle.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" />
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" />
AvatarImageView
1. app:image_radius="12" (integer)
2. app:image_margin="5" (integer)
3. app:image_shape="normal" or "round" or "curved" (String)
4. app:text_size="18" (float)
5. app:font_family="@font/your_font_name" (reference)
<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);
UserAvatar userAvatar = new UserAvatar("https://yourimageurl or file absolute path", "Avatar Name");
avatarImageView.setAvatar(userAvatar);
<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
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:text_size="26"
app:font_family="@font/your_font_name" />
DemoApp Coming Soon!!!