Using CircledImageView in android wear

馋奶兔 提交于 2019-12-25 06:25:12

问题


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?


回答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" />



回答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



来源:https://stackoverflow.com/questions/43538785/using-circledimageview-in-android-wear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!