### Configure Gradle Dependencies
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Add the library to your project via Maven Central in your build.gradle files.
```groovy
// build.gradle (project level)
repositories {
mavenCentral()
}
// build.gradle (app level)
dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'
}
```
--------------------------------
### Enable ProGuard in project.properties
Source: https://github.com/makeramen/roundedimageview/blob/main/example/proguard-project.txt
To enable ProGuard, define the proguard.config property in your project.properties file. This appends custom rules to the default Android ProGuard configuration.
```properties
# Add project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
```
--------------------------------
### Create RoundedDrawable from Bitmap
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Demonstrates creating a RoundedDrawable from a Bitmap and using the fluent API for configuration.
```java
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Shader;
import android.widget.ImageView.ScaleType;
import com.makeramen.roundedimageview.Corner;
import com.makeramen.roundedimageview.RoundedDrawable;
// Create RoundedDrawable from bitmap
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.photo);
RoundedDrawable drawable = RoundedDrawable.fromBitmap(bitmap);
// Configure with fluent API (method chaining)
drawable.setScaleType(ScaleType.CENTER_CROP)
.setCornerRadius(30f)
.setBorderWidth(3f)
.setBorderColor(Color.BLACK)
.setOval(false)
.setTileModeX(Shader.TileMode.CLAMP)
.setTileModeY(Shader.TileMode.CLAMP);
// Set individual corner radii
drawable.setCornerRadius(Corner.TOP_LEFT, 20f)
.setCornerRadius(Corner.TOP_RIGHT, 20f)
.setCornerRadius(Corner.BOTTOM_LEFT, 0f)
.setCornerRadius(Corner.BOTTOM_RIGHT, 0f);
// Or set all corners at once
drawable.setCornerRadius(20f, 20f, 0f, 0f);
// Use with any ImageView
imageView.setImageDrawable(drawable);
// Get source bitmap
Bitmap sourceBitmap = drawable.getSourceBitmap();
// Convert back to bitmap
Bitmap roundedBitmap = drawable.toBitmap();
```
--------------------------------
### RoundedImageView Programmatic Configuration
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Create and configure RoundedImageView instances programmatically using fluent setters. Supports pixel values, dimension resources, and ColorStateList for borders.
```java
import android.graphics.Color;
import android.graphics.Shader;
import android.widget.ImageView.ScaleType;
import com.makeramen.roundedimageview.Corner;
import com.makeramen.roundedimageview.RoundedImageView;
// Create RoundedImageView programmatically
RoundedImageView riv = new RoundedImageView(context);
// Set image source
riv.setImageResource(R.drawable.photo);
riv.setImageBitmap(bitmap);
riv.setImageDrawable(drawable);
// Configure scale type (all standard Android ScaleTypes supported)
riv.setScaleType(ScaleType.CENTER_CROP);
// Set uniform corner radius for all corners
riv.setCornerRadius(30f); // in pixels
riv.setCornerRadiusDimen(R.dimen.corner_radius); // from dimension resource
// Set individual corner radii
riv.setCornerRadius(Corner.TOP_LEFT, 20f);
riv.setCornerRadius(Corner.TOP_RIGHT, 20f);
riv.setCornerRadius(Corner.BOTTOM_LEFT, 10f);
riv.setCornerRadius(Corner.BOTTOM_RIGHT, 10f);
// Or set all corners at once
riv.setCornerRadius(20f, 20f, 10f, 10f); // topLeft, topRight, bottomLeft, bottomRight
// Configure border
riv.setBorderWidth(3f); // in pixels
riv.setBorderWidth(R.dimen.border_width); // from dimension resource
riv.setBorderColor(Color.DKGRAY);
riv.setBorderColor(colorStateList); // for state-aware colors
// Enable oval/circle mode (ignores corner radii)
riv.setOval(true);
// Configure tile modes for repeating drawables
riv.setTileModeX(Shader.TileMode.REPEAT);
riv.setTileModeY(Shader.TileMode.MIRROR);
// Enable background mutation (applies rounding to background drawable too)
riv.mutateBackground(true);
riv.setBackground(backgroundDrawable);
```
--------------------------------
### Create Picasso Transformations with RoundedTransformationBuilder
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Use the builder pattern to define rounded corner and border configurations for Picasso image loading pipelines.
```java
import android.graphics.Color;
import android.widget.ImageView;
import com.makeramen.roundedimageview.Corner;
import com.makeramen.roundedimageview.RoundedTransformationBuilder;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Transformation;
// Build transformation with rounded corners
Transformation transformation = new RoundedTransformationBuilder()
.cornerRadiusDp(30) // All corners in dp
.borderWidthDp(3) // Border width in dp
.borderColor(Color.BLACK) // Border color
.oval(false) // Oval mode
.scaleType(ImageView.ScaleType.CENTER_CROP)
.build();
// Use with Picasso
Picasso.with(context)
.load("https://example.com/image.jpg")
.fit()
.transform(transformation)
.into(imageView);
// Build transformation with pixel values
Transformation pixelTransformation = new RoundedTransformationBuilder()
.cornerRadius(50f) // All corners in pixels
.borderWidth(5f) // Border width in pixels
.borderColor(colorStateList) // ColorStateList for state-aware borders
.build();
// Build transformation with individual corner radii
Transformation selectiveTransformation = new RoundedTransformationBuilder()
.cornerRadiusDp(Corner.TOP_LEFT, 20)
.cornerRadiusDp(Corner.TOP_RIGHT, 20)
.cornerRadiusDp(Corner.BOTTOM_LEFT, 0)
.cornerRadiusDp(Corner.BOTTOM_RIGHT, 0)
.borderWidthDp(2)
.borderColor(Color.GRAY)
.build();
// Build oval transformation
Transformation ovalTransformation = new RoundedTransformationBuilder()
.oval(true)
.borderWidthDp(4)
.borderColor(Color.WHITE)
.build();
Picasso.with(context)
.load(imageUrl)
.fit()
.transform(ovalTransformation)
.into(profileImageView);
```
--------------------------------
### Configure RoundedImageView Programmatically
Source: https://github.com/makeramen/roundedimageview/blob/main/README.md
Set view properties dynamically using Java code.
```java
RoundedImageView riv = new RoundedImageView(context);
riv.setScaleType(ScaleType.CENTER_CROP);
riv.setCornerRadius((float) 10);
riv.setBorderWidth((float) 2);
riv.setBorderColor(Color.DKGRAY);
riv.mutateBackground(true);
riv.setImageDrawable(drawable);
riv.setBackground(backgroundDrawable);
riv.setOval(true);
riv.setTileModeX(Shader.TileMode.REPEAT);
riv.setTileModeY(Shader.TileMode.REPEAT);
```
--------------------------------
### Add RoundedImageView Dependency
Source: https://github.com/makeramen/roundedimageview/blob/main/README.md
Include the library in your project via Gradle.
```gradle
repositories {
mavenCentral()
}
dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'
}
```
--------------------------------
### Define RoundedImageView in XML
Source: https://github.com/makeramen/roundedimageview/blob/main/README.md
Configure the view properties directly within your layout XML files.
```xml
```
--------------------------------
### Apply Rounded Transformation with Picasso
Source: https://github.com/makeramen/roundedimageview/blob/main/README.md
Use the RoundedTransformationBuilder to create a transformation for Picasso image loading.
```java
Transformation transformation = new RoundedTransformationBuilder()
.borderColor(Color.BLACK)
.borderWidthDp(3)
.cornerRadiusDp(30)
.oval(false)
.build();
Picasso.with(context)
.load(url)
.fit()
.transform(transformation)
.into(imageView);
```
--------------------------------
### Utilize Corner Constants for Custom Radii
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Apply specific corner radii to RoundedImageView or RoundedDrawable using predefined Corner constants.
```java
import com.makeramen.roundedimageview.Corner;
import com.makeramen.roundedimageview.RoundedImageView;
import com.makeramen.roundedimageview.RoundedDrawable;
// Corner constants
int topLeft = Corner.TOP_LEFT; // 0
int topRight = Corner.TOP_RIGHT; // 1
int bottomRight = Corner.BOTTOM_RIGHT; // 2
int bottomLeft = Corner.BOTTOM_LEFT; // 3
// Use with RoundedImageView
RoundedImageView riv = new RoundedImageView(context);
riv.setCornerRadius(Corner.TOP_LEFT, 30f);
riv.setCornerRadius(Corner.TOP_RIGHT, 30f);
riv.setCornerRadius(Corner.BOTTOM_LEFT, 0f);
riv.setCornerRadius(Corner.BOTTOM_RIGHT, 0f);
// Use with RoundedDrawable
RoundedDrawable drawable = RoundedDrawable.fromBitmap(bitmap);
drawable.setCornerRadius(Corner.TOP_LEFT, 20f)
.setCornerRadius(Corner.BOTTOM_RIGHT, 20f);
// Get corner radius for specific corner
float topLeftRadius = riv.getCornerRadius(Corner.TOP_LEFT);
float maxRadius = riv.getMaxCornerRadius();
```
--------------------------------
### Implement RoundedImageView in an Adapter
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Configures RoundedImageView properties dynamically within a ListView or RecyclerView adapter to ensure smooth performance.
```java
import android.graphics.BitmapFactory;
import android.graphics.Shader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView.ScaleType;
import com.makeramen.roundedimageview.RoundedImageView;
public class ImageAdapter extends ArrayAdapter {
private final LayoutInflater inflater;
public ImageAdapter(Context context) {
super(context, 0);
inflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewGroup view;
if (convertView == null) {
view = (ViewGroup) inflater.inflate(R.layout.image_item, parent, false);
} else {
view = (ViewGroup) convertView;
}
ImageItem item = getItem(position);
RoundedImageView imageView = view.findViewById(R.id.imageView1);
// Configure based on item properties
imageView.setOval(item.isOval());
imageView.setImageBitmap(item.getBitmap());
imageView.setScaleType(item.getScaleType());
imageView.setTileModeX(item.getTileMode());
imageView.setTileModeY(item.getTileMode());
return view;
}
}
```
--------------------------------
### RoundedImageView XML Attributes
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Configure RoundedImageView directly in XML layouts using attributes prefixed with 'riv_'. Supports corner radius, border, oval mode, and tile modes.
```xml
```
--------------------------------
### Convert Existing Drawable to RoundedDrawable
Source: https://context7.com/makeramen/roundedimageview/llms.txt
Converts various Android Drawable types, including LayerDrawable, into a RoundedDrawable.
```java
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import com.makeramen.roundedimageview.RoundedDrawable;
// Convert any drawable to RoundedDrawable
Drawable originalDrawable = getResources().getDrawable(R.drawable.photo);
Drawable roundedDrawable = RoundedDrawable.fromDrawable(originalDrawable);
// The method handles various cases:
// - If already RoundedDrawable, returns as-is
// - If LayerDrawable, converts each layer recursively
// - If BitmapDrawable, extracts bitmap and wraps
// - For other drawables, rasterizes to bitmap
// Configure the rounded drawable
if (roundedDrawable instanceof RoundedDrawable) {
((RoundedDrawable) roundedDrawable)
.setCornerRadius(20f)
.setBorderWidth(2f)
.setBorderColor(Color.WHITE);
}
// Works with LayerDrawable (e.g., TransitionDrawable for fade effects)
LayerDrawable layerDrawable = (LayerDrawable) getResources()
.getDrawable(R.drawable.layer_list);
Drawable roundedLayers = RoundedDrawable.fromDrawable(layerDrawable);
imageView.setImageDrawable(roundedLayers);
// Static utility to convert any drawable to bitmap
Bitmap bitmap = RoundedDrawable.drawableToBitmap(anyDrawable);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.