Reputation: 2103
In my XML layout, I use this code to create a specific shape for my imageview:
<com.makeramen.roundedimageview.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/avatar"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/adduserprofile"
android:scaleType="centerCrop"
app:riv_border_width="5dip"
app:riv_border_color="#ff9800"
app:riv_mutate_background="true"
app:riv_oval="false"
app:riv_corner_radius_bottom_right="15dp"
app:riv_corner_radius_top_left="15dp"
app:riv_corner_radius_bottom_left="15dp"
/>
and then I load the image with Picasso in this way:
Picasso.get().load(url.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).networkPolicy(NetworkPolicy.NO_CACHE).into(p_avatar);
Is there any possibility to change the border color in Java by using Picasso or any other method? I would like to change the border color depending on some user's events.
Thank you!
Upvotes: 0
Views: 773
Reputation: 171
try it.
((RoundedImageView) view.findViewById(R.id.avatar)).setBorderColor(getResources().getColor(android.R.color.black));
((RoundedImageView) view.findViewById(R.id.avatar)).setBorderWidth(position * 5);
((RoundedImageView) view.findViewById(R.id.avatar)).setCornerRadius(position * 5);
((RoundedImageView) view.findViewById(R.id.avatar)).setImageBitmap(item.mBitmap);
((RoundedImageView) view.findViewById(R.id.avatar)).setScaleType(item.mScaleType);
Upvotes: 1
Reputation: 331
You can use Transformation object to set properties of the shape. Use different Transformation object for different events.
Transformation transformation = new RoundedTransformationBuilder()
.borderColor(Color.BLACK)
.borderWidthDp(3)
.cornerRadiusDp(30)
.oval(false)
.build();
Picasso.with(context)
.load(url)
.fit()
.transform(transformation)
.into(imageView);
You should check the README of library before using it.
Upvotes: 1