Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vitorhugods/AvatarView
A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.
https://github.com/vitorhugods/AvatarView
android android-library android-ui hacktoberfest imageview kotlin-android kotlin-library progress-animation progress-bar progress-circle widget
Last synced: 29 days ago
JSON representation
A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.
- Host: GitHub
- URL: https://github.com/vitorhugods/AvatarView
- Owner: vitorhugods
- License: apache-2.0
- Created: 2018-09-21T11:03:12.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2022-09-22T12:23:18.000Z (about 2 years ago)
- Last Synced: 2024-08-03T20:08:22.079Z (4 months ago)
- Topics: android, android-library, android-ui, hacktoberfest, imageview, kotlin-android, kotlin-library, progress-animation, progress-bar, progress-circle, widget
- Language: Kotlin
- Homepage:
- Size: 4.79 MB
- Stars: 547
- Watchers: 7
- Forks: 38
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-gradient - AvatarView - A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color. (Kotlin)
README
# AvatarView
A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.[![Gradle](https://img.shields.io/badge/MavenCentral-1.2.0-brightgreen.svg)](https://github.com/vitorhugods/AvatarView/releases)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e4847d7f36754c1a8efb1aff838fdb91)](https://app.codacy.com/app/vitorhugods/AvatarView?utm_source=github.com&utm_medium=referral&utm_content=vitorhugods/AvatarView&utm_campaign=Badge_Grade_Dashboard)
![Kotlin](https://img.shields.io/badge/minSdkVersion-14-brightgreen.svg)
![Kotlin](https://img.shields.io/badge/Kotlin-100%25-orange.svg)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/[email protected])
### Samples
| | |
|:-:|:-:|
| | |
| | |Supports initials if no image is provided:
Thanks to [@anoop44](https://github.com/anoop44)
Supports a badge, for "online/offline" status or other use cases:
Thanks to [@p1yu5h](https://github.com/p1yu5h)
## Demo
[Watch the video](https://vimeo.com/291110435) or clone the repo and build the demo app## Gradle setup
Make sure you have the MavenCentral in your list of repositories.
* Kotlin DSL `build.gradle.kts`
```kotlin
dependencies {
implementation("xyz.schwaab:avvylib:1.2.0")
}
```
* Or, Groovy `build.gradle`
```gradle
dependencies {
implementation "xyz.schwaab:avvylib:1.2.0"
}
```## Usage
Just add this to your XML:
```xml
```Add the name initials as fallback:
```xml
app:avvy_text="Avatar View" //will show up as AV
app:avvy_text_size="42sp"
app:avvy_text_color="#ccc"
```Add the badge if you want:
```xml
app:avvy_show_badge="true" //Default = false
app:avvy_badge_radius="18dp"
app:avvy_badge_stroke_width="2dp"
app:avvy_badge_stroke_color="@color/white"
app:avvy_badge_position="BOTTOM_RIGHT" //Default value
```You can personalize it in Kotlin:
```kotlin
avatarView.apply {
isAnimating = false
borderThickness = 18
highlightBorderColor = Color.GREEN
highlightBorderColorEnd = Color.CYAN
numberOfArches = 0
totalArchesDegreeArea = 80
text = "Avatar View"
showBadge = true
badgePosition = BadgePosition.TOP_LEFT
}
```Or, in Java:
```java
avatarView.setAnimating(false);
avatarView.setBorderThickness(18);
avatarView.setHighlightBorderColor(Color.GREEN);
avatarView.setHighlightBorderColorEnd(Color.CYAN);
avatarView.setNumberOfArches(0);
avatarView.setTotalArchesDegreeArea(80);
```### Custom Animations
Create an AvatarViewAnimationOrchestrator, passing at least one AvatarViewAnimator.
The `setupAnimators` are the first running, and they run in reverse when animation is stopping. They should not repead infinitely, so the `progressAnimators` can start.
The `progressAnimators` can run indefinitely.You don't need to use both setup and progress, just one is enough. But, by having the setup having a finite duration, and reversible, it allows for a smoother animation stop.
Example:
```kotlinval archesExpansion = object: AvatarViewAnimator{
override val baseAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
duration = 500L
interpolator = DecelerateInterpolator()
}
override fun onValueUpdate(animatorInterface: AvatarView.AnimatorInterface) {
val animatedValue = baseAnimator.animatedValue as Float
animatorInterface.updateAnimationState { currentState ->
currentState.copy(archesExpansionProgress = animatedValue)
}
}
}
val bouncingRotation = object : AvatarViewAnimator {
override val baseAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
repeatCount = ValueAnimator.INFINITE
duration = 3000L
interpolator = BounceInterpolator()
}
override fun onValueUpdate(animatorInterface: AvatarView.AnimatorInterface) {
val animatedValue = baseAnimator.animatedValue as Float
animatorInterface.updateAnimationState { currentState ->
currentState.copy(rotationProgress = animatedValue)
}
}
}avatarView.animationOrchestrator = AvatarViewAnimationOrchestrator(archesExpansion, bouncingRotation)
```Check the sample app for the full source code.
### Special Thanks
The roundness of the drawables based on [Henning Dodenhof's Circle ImageView](https://github.com/hdodenhof/CircleImageView)Libraries used in the demo app:
- [QuadFlask Color Picker](https://github.com/QuadFlask/colorpicker)
- [Bubbleseekbar](https://github.com/woxingxiao/BubbleSeekBar)
License
-------Copyright 2020 Vitor Hugo D. Schwaab
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 athttp://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.