title: How to add a shadow and a border on circular imageView android?
body: <p>I created a CircularImageView with this question: <a href="https://stackoverflow.com/q/16208365/1832221">Create circular image view in android</a></p>
  
  <p>Download project on <a href="https://github.com/lopspower/CircularImageView" rel="noreferrer"><strong>GitHub</strong></a></p>
  
  <p>1) This is the CircularImageView class :</p>
  
  <pre><code>public class CircularImageView extends ImageView {
      public CircularImageView(Context context) {
          super(context);
      }
  
      public CircularImageView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public CircularImageView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          Drawable drawable = getDrawable();
          if (drawable == null) {
              return;
          }
  
          if (getWidth() == 0 || getHeight() == 0) {
              return; 
          }
          Bitmap b =  ((BitmapDrawable)drawable).getBitmap() ;
          Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);      
  
          Bitmap roundBitmap =  getCroppedBitmap(bitmap, getWidth());
          canvas.drawBitmap(roundBitmap, 0, 0, null);
      }
  
      public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
          Bitmap sbmp;
          if(bmp.getWidth() != radius || bmp.getHeight() != radius)
              sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false);
          else
              sbmp = bmp;
  
          Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), sbmp.getHeight(), Bitmap.Config.ARGB_8888);
          final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight());
  
          Paint paint = new Paint();
          paint.setAntiAlias(true);
          paint.setFilterBitmap(true);
          paint.setDither(true);      
          paint.setColor(Color.parseColor("#BAB399"));
  
          Canvas c = new Canvas(output);        
          c.drawARGB(0, 0, 0, 0);
          c.drawCircle(sbmp.getWidth() / 2+0.7f, sbmp.getHeight() / 2+0.7f, sbmp.getWidth() / 2+0.1f, paint);
          paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
          c.drawBitmap(sbmp, rect, rect, paint);
  
          return output;
      }
  }
  </code></pre>
  
  <p>2) I use in my layout like this :</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#cccccc"
      android:gravity="center"
      android:orientation="vertical"
      android:padding="10dp" &gt;
  
      &lt;com.mikhaellopez.circularimageview.CircularImageView
          android:id="@+id/imageViewCircular"
          android:layout_width="@dimen/image_view_size"
          android:layout_height="@dimen/image_view_size"
          android:layout_gravity="center"
          android:background="@drawable/border"
          android:src="@drawable/image" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>3) Current result in picture :</p>
  
  <p><img src="https://i.stack.imgur.com/kdrpp.png" alt="Current result"></p>
  
  <p><strong>How do I change this code to have a shadow and a circular border around my imageView?</strong></p>
  
  <p>Objectif result :</p>
  
  <p><img src="https://i.stack.imgur.com/MG6ba.png" alt="Objectif result"></p>
  
  <hr>
  
  <p><strong>Edit 10/15/2015 :</strong></p>
  
  <p>You can used or download my <strong>GitHub library</strong> <a href="https://github.com/lopspower/CircularImageView" rel="noreferrer"><strong>CircularImageView</strong></a> with <strong>all the fixes</strong> by using <strong>gradle dependency</strong> :</p>
  
  <pre><code>compile 'com.mikhaellopez:circularimageview:2.0.1'
  </code></pre>