Need help with RoundedImageView?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

vinc3m1
6.2K Stars 1.2K Forks Other 259 Commits 35 Opened issues

Description

A fast ImageView that supports rounded corners, ovals, and circles.

Services available

!
?

Need anything else?

Contributors list

# 12,294
Java
Shell
Android
Groovy
189 commits
# 103,624
Java
Shell
Kotlin
lyft
5 commits
# 10,385
Java
Shell
Android
kotlin-...
4 commits
# 98,986
Java
Shell
android...
Groovy
3 commits
# 110,210
Java
HTML
swagger...
swagger
3 commits
# 109,394
Haskell
PureScr...
pandoc
markup
2 commits
# 157,781
Java
android...
Android
2 commits
# 105,690
Groovy
HTML
iOS
hotfix
1 commit
# 104,425
Android
c-plus-...
Shell
capture...
1 commit
# 6,085
Java
C#
browser...
bittorr...
1 commit
# 19,804
Swift
dateran...
dateran...
Kotlin
1 commit
# 99,626
Java
Kotlin
Shell
1 commit
# 179,955
C#
F#
1 commit
# 58,183
Java
uber
rxandro...
Kotlin
1 commit
# 181,722
Android
HTML
markup-...
Markdow...
1 commit
# 9,793
autohot...
ahk
bitwise...
Nette
1 commit
# 41,267
Swift
Android
Kotlin
Firebas...
1 commit
# 214,358
Java
1 commit

RoundedImageView

Maven Central Android Arsenal

A fast ImageView (and Drawable) that supports rounded corners (and ovals or circles) based on the original example from Romain Guy. It supports many additional features including ovals, rounded rectangles, ScaleTypes and TileModes.

RoundedImageView screenshot RoundedImageView screenshot with ovals

There are many ways to create rounded corners in android, but this is the fastest and best one that I know of because it: * does not create a copy of the original bitmap * does not use a clipPath which is not hardware accelerated and not anti-aliased. * does not use setXfermode to clip the bitmap and draw twice to the canvas.

If you know of a better method, let me know (or even better open a pull request)!

Also has proper support for: * Borders (with Colors and ColorStateLists) * Ovals and Circles * All

ScaleType
s * Borders are drawn at view edge, not bitmap edge * Except on edges where the bitmap is smaller than the view * Borders are not scaled up/down with the image (correct width and radius are maintained) * Anti-aliasing * Transparent backgrounds * Hardware acceleration * Support for LayerDrawables (including TransitionDrawables) * TileModes for repeating drawables

Known Issues

  • VectorDrawables are not supported. This library is designed for BitmapDrawables only. Other drawables will likely fail or cause high memory usage.
  • ColorDrawables are poorly supported, use your own rounded VectorDrawables instead if you want less memory pressure.
  • Glide transforms are not supported, please use wasabeef/glide-transformations if you want to round images loaded from Glide.

Gradle

RoundedImageView is available in Maven Central.

Add the following to your

build.gradle
to use: ``` repositories { mavenCentral() }

dependencies { implementation 'com.makeramen:roundedimageview:2.3.0' } ```

Usage

Define in xml:


Or in code:

RoundedImageView riv = new RoundedImageView(context);
riv.setScaleType(ScaleType.CENTER_CROP);
riv.setCornerRadius((float) 10);
riv.setBorderWidth((float) 2);
riv.setBorderColor(Color.DKGRAY);
riv.mutateBackground(true);
riv.setImageDrawable(drawable);
riv.setBackground(backgroundDrawable);
riv.setOval(true);
riv.setTileModeX(Shader.TileMode.REPEAT);
riv.setTileModeY(Shader.TileMode.REPEAT);

Picasso

To make a Transformation for Picasso:

Transformation transformation = new RoundedTransformationBuilder()
          .borderColor(Color.BLACK)
          .borderWidthDp(3)
          .cornerRadiusDp(30)
          .oval(false)
          .build();

Picasso.with(context) .load(url) .fit() .transform(transformation) .into(imageView);

Changelog

see Releases

License

Copyright 2017 Vincent Mi

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.