Circle imageview android studio

Circle imageview android studio

This is an Android project allowing to realize a circular ImageView in the simplest way possible.

To make a circular ImageView add CircularImageView in your layout XML and add CircularImageView library in your project or you can also grab it via Gradle:

You must use the following properties in your XML to change your CircularImageView.

Properties Type Default
app:civ_circle_color color WHITE
app:civ_circle_color_start color civ_circle_color
app:civ_circle_color_end color civ_circle_color
app:civ_color_direction left_to_right, right_to_left, top_to_bottom or bottom_to_top left_to_right
app:civ_border boolean true
app:civ_border_width dimension 4dp
app:civ_border_color color WHITE
app:civ_border_color_start color civ_border_color
app:civ_border_color_end color civ_border_color
app:civ_border_color_direction left_to_right, right_to_left, top_to_bottom or bottom_to_top left_to_right
app:civ_shadow boolean false
app:civ_shadow_color color BLACK
app:civ_shadow_radius dimension 8dp
app:civ_shadow_gravity center, top, bottom, start or end bottom

ℹ️ You can also use android:elevation instead of app:civ_shadow to have default Material Design elevation.

Источник

Circle imageview android studio

A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniques recommended by Romain Guy.

It uses a BitmapShader and does not:

  • create a copy of the original bitmap
  • use a clipPath (which is neither hardware accelerated nor anti-aliased)
  • use setXfermode to clip the bitmap (which means drawing twice to the canvas)

As this is just a custom ImageView and not a custom Drawable or a combination of both, it can be used with all kinds of drawables, i.e. a PicassoDrawable from Picasso or other non-standard drawables (needs some testing though).

  • The ScaleType is always CENTER_CROP and you’ll get an exception if you try to change it. This is (currently) by design as it’s perfectly fine for profile images.
  • Enabling adjustViewBounds is not supported as this requires an unsupported ScaleType
  • If you use an image loading library like Picasso or Glide, you need to disable their fade animations to avoid messed up images. For Picasso use the noFade() option, for Glide use dontAnimate() . If you want to keep the fadeIn animation, you have to fetch the image into a Target and apply a custom animation yourself when receiving the Bitmap .
  • Using a TransitionDrawable with CircleImageView doesn’t work properly and leads to messed up images.

How can I use a VectorDrawable with CircleImageView ?

Short answer: you shouldn’t. Using a VectorDrawable with CircleImageView is very inefficient. You should modify your vectors to be in a circular shape and use them with a regular ImageView instead.

Why doesn’t CircleImageView extend AppCompatImageView ?

Extending AppCompatImageView would require adding a runtime dependency for the support library without any real benefit.

How can I add a selector (e.g. ripple effect) bound to a circle?

There’s currently no direct support for a circle bound selector but you can follow these steps to implement it yourself.

How can I add a gap between image and border?

Adding a gap is also not supported directly but there’s a workaround.

Источник

Читайте также:  Как сменить вид клавиатуры андроид
Оцените статью