CircularImageView
Circle image view :red_circle: and Avatar image view :smiley: for android
Install / Use
/learn @abdularis/CircularImageViewREADME
Android Circular Image View
This library provides you circle and avatar imageview for android. it automatically scale and center a bitmap based on the size of the view but does not copy the bitmap itself.
Read this article:
Screenshot
|
|
|
|-|-|
Setup
- Step 1 Add repository into root build.gradle
allprojects {
repositories {
...
maven {
url 'https://jitpack.io' }
}
}
- Step 2 Add library dependency into app build.gradle
See the jitpack badge above for the latest version number
dependencies {
implementation 'com.github.abdularis:circularimageview:<latest-version>'
}
Usage
Check also the sample app
- Creating circle image view

<com.github.abdularis.civ.CircleImageView
android:layout_width="100dp"
android:layout_height="170dp"
android:src="@drawable/figure"
app:highlightColor="#80fb1743"
app:strokeColor="@color/colorAccent"
app:strokeWidth="2px"/>
<com.github.abdularis.civ.CircleImageView
android:layout_width="160dp"
android:layout_height="160dp"
android:src="@drawable/figure2"
android:onClick="onCircleImageClick"
app:strokeColor="@color/colorAccent"/>
- Creating avatar

You can choose either for avatar view state, IMAGE or INITIAL to show the first letter (default is INITIAL)
<com.github.abdularis.civ.AvatarImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/figure"
android:onClick="onAClick"
app:strokeWidth="1dp"
app:strokeColor="@android:color/white"
app:avatarBackgroundColor="@color/colorAccent"
app:text="A"
app:textSize="22sp"/>
<com.github.abdularis.civ.AvatarImageView
android:layout_width="60dp"
android:layout_height="60dp"
app:highlightEnable="false"
app:strokeColor="#64B5F6"
app:strokeWidth="1dp"
app:avatarBackgroundColor="#8E24AA"
app:text="B"
app:textSize="22sp"/>
<com.github.abdularis.civ.AvatarImageView
android:layout_width="60dp"
android:layout_height="60dp"
app:avatarBackgroundColor="#FDFD00"
app:text="C"
app:textSize="22sp"
app:textColor="#3d3d01"/>
<com.github.abdularis.civ.AvatarImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/figure2"
app:strokeColor="#1976D2"
app:strokeWidth="1dp"
app:view_state="IMAGE"
app:avatarBackgroundColor="#1976D2"
app:text="B"
app:textSize="22sp"/>
Java on view click listener
// on click listener for avatar view 'A'
public void onAClick(View view) {
AvatarImageView a = (AvatarImageView) view;
if (a.getState() == AvatarImageView.SHOW_INITIAL) {
a.setState(AvatarImageView.SHOW_IMAGE);
} else {
a.setState(AvatarImageView.SHOW_INITIAL);
}
}
XML Attributes
These are all attributes that you can use to customize the appearance of CircleImageView and AvatarImageView
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CircleImageView">
<attr name="strokeColor" format="color"/>
<attr name="strokeWidth" format="dimension"/>
<attr name="highlightEnable" format="boolean"/>
<attr name="highlightColor" format="color"/>
</declare-styleable>
<declare-styleable name="AvatarImageView">
<attr name="avatarBackgroundColor" format="color"/>
<attr name="textSize" format="dimension"/>
<attr name="textColor" format="color"/>
<attr name="text" format="string"/>
<attr name="view_state" format="enum">
<enum name="INITIAL" value="1"/>
<enum name="IMAGE" value="2"/>
</attr>
</declare-styleable>
</resources>
License
Copyright 2018 abdularis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
