RoundedImageView-Library

Rounded ImageView Android Library, to set single or multiple corners on imageview.

RoundedImageView

Usage

Step 1. Add the JitPack repository to your build file

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

Step 2. Add the dependency

dependencies {
  compile 'com.github.DushyantMainwal:RoundedImageView-Library:0.3.0'
 }

Implementation

XML Implementation:

 <com.dushyant.roundedimageviewlibrary.RoundedImageView
            android:id="@+id/image_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:scaleType="centerCrop"
            app:border="true"
            app:borderColor="#089"
            app:borderWidth="10dp"
            app:canvasPadding="10"
            app:imagePadding="10"
            app:cornerRadius="30"
            app:src="@drawable/rdjimage"
            app:cornerType="bottomLeft"/>
        

Java Implementation:

        RoundedImageView customImageView = findViewById(R.id.image_view);
        customImageView.setImageResource(R.drawable.rdjimage);
        customImageView.setImageScaleType(RoundedImageView.ScaleType.CENTRE_CROP);
        
        //For Single Corner
        customImageView.setCornerType(RoundedImageView.CornerType.BOTTOM_RIGHT_CORNER);

        customImageView.setImagePadding(20);
        customImageView.setCanvasPadding(50);

        customImageView.setBorder(true);
        customImageView.setBorderColor(Color.DKGRAY);
        customImageView.setBorderWidth(40);
        
        customImageView.setCornerRadius(30);

        //For Multiple Corners
        List<RoundedImageView.CornerType> cornerTypes = new ArrayList<>();
        cornerTypes.add(RoundedImageView.CornerType.TOP_LEFT_CORNER);
        cornerTypes.add(RoundedImageView.CornerType.TOP_RIGHT_CORNER);
        customImageView.setCornerTypeList(cornerTypes);

Picasso Implementation:

         Picasso.with(this).load("https://www.gstatic.com/webp/gallery/5.sm.jpg").into(customImageView);

Glide Implementation:

         Glide.with(this)
                .load("https://www.w3schools.com/w3css/img_lights.jpg")
                .asBitmap()
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        customImageView.setImageBitmap(resource);
                    }
                });
                
        //With Drawable
        Glide.with(this)
                .load("https://www.w3schools.com/w3css/img_lights.jpg")
                .into(new SimpleTarget<GlideDrawable>() {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                        customImageView.setImageDrawable(resource);
                    }
                });

GitHub