Using CircledImageView In Android Wear
I am using the CircledImageView to display the image in the ListView, but I am not getting the image view as circular. Can anyone tell me how to achieve this?
Solution 1:
ok got it woking by setting the height and width as wrap content and also providig the radius of the cirlce.
Here is the code working for me.
<android.support.wearable.view.CircledImageView
android:id="@+id/im_action_icons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:circle_border_color="#FFFFFFFF"
app:circle_border_width="2dp"
app:circle_color="@color/blue"
app:circle_radius="23dp" />
Solution 2:
Try this short code it works for me:
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(Activity.this.getResources(), yourbitmap);
roundedBitmapDrawable.setCircular(true);
your imageview.setImageDrawable(roundedBitmapDrawable);
If you use Glide library to download images you can do something like this.
Glide.with(context).load(your image url).asBitmap().placeholder(your default place holder).error(error place holder).into(new BitmapImageViewTarget(your imageview) {
@Override
protected void setResource(Bitmap resource) {
super.setResource(resource);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(Activity.this.getResources(), resource);
roundedBitmapDrawable.setCircular(true);
your imageview.setImageDrawable(roundedBitmapDrawable);
}
});
You can also do these thing with Picasso library
Post a Comment for "Using CircledImageView In Android Wear"