Skip to content

Easy to use, lightweight custom image view with rounded corners.

Notifications You must be signed in to change notification settings

mmmelik/RoundedImageView

Repository files navigation


Logo

RoundedImageView

Easy to use, lightweight custom image view with rounded corners.
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

Product Name Screen Shot

This library allows you to create ImageViews with soft edges that are pleasing to the eye.

Built With

Getting Started

To make this view running on your app follow these simple steps.

1. Add the JitPack repository to your project level build.gradle file

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

2. Add the dependency to your module level build.gradle file

dependencies {
  implementation 'com.github.mmmelik:RoundedImageView:v1.0.1'
}

Usage

RoundedImageView extends ImageView so all functions of ImageView are available for RoundedImageView.

Java


RoundedImageView roundedImageView=findViewById(R.id.roundedImageView);
roundedImageView.setRadius(5); //Sets radius of all corners
roundedImageView.setRadius(RoundedImageView.Corner.BOTTOM_LEFT,50); //Override BOTTOM_LEFT corner.
roundedImageView.setImageDrawable(getResources().getDrawable(R.drawable.free)); //First set radius then set drawable.

XML


<com.appbroker.roundedimageview.RoundedImageView
        android:id="@+id/roundedImageView"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:src="@drawable/free"
        app:radius="50dp"/>

<com.appbroker.roundedimageview.RoundedImageView
        android:id="@+id/roundedImageView2"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:src="@drawable/free"
        app:topLeftRadius="10dp"
        app:topRightRadius="20dp"
        app:bottomRightRadius="30dp"
        app:bottomLeftRadius="40dp"/>

<com.appbroker.roundedimageview.RoundedImageView
        android:id="@+id/roundedImageView3"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:src="@drawable/free"
        app:radius="50dp"
        app:bottomRightRadius="0dp"/>

Troubleshooting

In RoundedImageView XML attribute android:adjustViewBounds set to true by default. If it cause unintended behaviour of the view override with android:adjustViewBounds="false".

RoundedImageView does not manipulate drawable of the view. Only clips out the corners of the view. So make sure you have fully wrapped drawable with the views borders.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Branch
  3. Commit your Changes
  4. Push to the Branch
  5. Open a Pull Request