2017-04-21 49 views
0

我正在使用CircledImageViewListView中顯示圖像,但我沒有將圖像視圖顯示爲循環圖像。任何人都可以告訴我如何實現這一目標?如果您使用Glide library下載,你可以做這樣的事情的圖像在Android Wear中使用CircledImageView

RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(Activity.this.getResources(), yourbitmap); 
roundedBitmapDrawable.setCircular(true); 
your imageview.setImageDrawable(roundedBitmapDrawable); 

+0

你能顯示你的代碼嗎? – Onez

回答

2

確定了它通過設置高度和寬度爲包裝的內容,也providig的cirlce半徑沃金。

這是我工作的代碼。

<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" /> 
0

試試這個短代碼它爲我工作。

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); 
     } 
    }); 

你也可以做這些事情與Picasso library