【问题标题】:Using CircledImageView in android wear在 Android Wear 中使用 CircledImageView
【发布时间】:2017-04-21 09:21:30
【问题描述】:

我正在使用CircledImageViewListView 中显示图像,但我没有将图像视图显示为圆形。谁能告诉我如何做到这一点?

【问题讨论】:

  • 你能展示你的代码吗?

标签: android android-layout wear-os


【解决方案1】:

好的,通过将高度和宽度设置为包装内容并提供圆的半径来实现它。

这是为我工作的代码。

 <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】:

    试试这个对我有用的短代码:

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

    如果你使用Glide library 下载图片,你可以这样做。

    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做这些事情

    【讨论】:

      猜你喜欢
      • 2014-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多