Reputation: 77
i Want To Load Image From Picasso Library in RoundedImageView
I am Taking Refrence From https://github.com/vinc3m1/RoundedImageView
I Really Unable To Understand How To Use For RoundedImageView
Can You please Tell Me How To use..I m Unable To understand..how to use
When I set Layout
<com.makeramen.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView1"
android:src="@drawable/photo1"
android:scaleType="centerCrop"
app:corner_radius="30dip"
app:border_width="2dip"
app:border_color="#333333"
app:mutate_background="true"
app:oval="true" />
instead Of ImageView...Giving Error ...
i dowloaded Java.doc.jar of roundedImageview from here http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.makeramen%22%20AND%20a%3A%22roundedimageview%22
and add to the libs folder and build path
After Adding ...no resourc Found
update
//tv_gender.setText(Gender);
iv = (ImageView)rootView.findViewById(R.id.imageView1);
tv_intrseted.setText(IntrestedIn);
// Button logout=(Button)rootView.findViewById(R.id.logout);
RoundedImageView iv = new RoundedImageView(context);
iv.setScaleType(ScaleType.CENTER_CROP);
iv.setCornerRadius(10);
iv.setBorderWidth(2);
iv.setBorderColor(Color.DKGRAY);
iv.setMutateBackground(true);
iv.setImageDrawable(drawable);
iv.setBackground(backgroundDrawable);
iv.setOval(true);
if I use Like This giving error ..Can not be Resolved RoundedImageView
Upvotes: 2
Views: 5149
Reputation: 1
Edit them to:
app:riv_corner_radius="30dip"
app:riv_border_width="2dip"
See this for more info.
Upvotes: 0
Reputation: 544
Make a transformation for Picasso.
Transformation transformation = new RoundedTransformationBuilder()
.borderColor(Color.BLACK)
.borderWidthDp(3)
.cornerRadiusDp(30)
.oval(false)
.build();
Picasso.with(context)
.load(url)
.fit()
.transform(transformation)
.into(imageView);
Upvotes: 0
Reputation:
Try to Use the library available try using https://github.com/Pkmmte/CircularImageView
for the rounded ImageView in android.First try to create a basic one.Androidgreeve here i found a article on creating roundImageview as in facebook messanger
Upvotes: 1
Reputation: 164
This is the procedure, what i followed for one of my project. Please, have a look. It may lead you to find the solution as per your requirement.
Create a class `RoundedTransform` and paste this code.
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import com.squareup.picasso.Transformation;
public class RoundedTransform implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
source.recycle();
}
Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap,
BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
squaredBitmap.recycle();
return bitmap;
}
@Override
public String key() {
return "circle";
}
}
Then while calling the image view in your Activity,call as follows
iv = (ImageView)rootView.findViewById(R.id.imageView1);
String imageUrl = "image";
String url = "Pass your url";
if(url!=null){
imageUrl = url;
}
Picasso.with(getApplicationContext()).load(imageUrl).fit().centerCrop().transform(new RoundedTransform()).placeholder(R.drawable.ic_launcher).error(R.drawable.ic_launcher).into((ImageView)findViewById(R.id.imageView1));
Upvotes: 0