Android Open Source - InstagramViewer Rounded Image View






From Project

Back to project page InstagramViewer.

License

The source code is released under:

MIT License

If you think the Android project InstagramViewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.codepath.instagramviewer;
/*  w  w w .  j  a v  a 2 s  .c om*/
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.ImageView;

public class RoundedImageView extends ImageView {

    public RoundedImageView(Context context) {
         super(context);
    }

    public RoundedImageView(Context context, AttributeSet attrs) {
         super(context, attrs);
    }

    public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
    }

    @Override
    protected void onDraw(Canvas canvas) {
         float radius = 90.0f; // angle of round corners
         Path clipPath = new Path();
         RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
         clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
         canvas.clipPath(clipPath);
         
         super.onDraw(canvas);
     }
  }




Java Source Code List

com.codepath.instagramviewer.DynamicImageView.java
com.codepath.instagramviewer.InstagramPhotoAdapter.java
com.codepath.instagramviewer.InstagramPhoto.java
com.codepath.instagramviewer.PhotosActivity.java
com.codepath.instagramviewer.RoundedImageView.java