为了账号安全,请及时绑定邮箱和手机立即绑定

如何制作圆角图像视图?

如何制作圆角图像视图?

宝慕林4294392 2019-06-01 15:24:25
如何制作圆角图像视图?在Android中,默认情况下,ImageView是一个矩形。如何使其成为图像视图中的圆角矩形(将位图的所有四个角剪辑为圆角矩形)?
查看完整描述

4 回答

?
慕容708150

TA贡献1831条经验 获得超4个赞

另一种简单的方法是使用带有拐角半径的CardView和内部的ImageView:

  <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardCornerRadius="8dp"
            android:layout_margin="5dp"
            android:elevation="10dp">

            <ImageView
                android:id="@+id/roundedImageView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/image"
                android:background="@color/white"
                android:scaleType="centerCrop"
                />
        </android.support.v7.widget.CardView>


查看完整回答
反对 回复 2019-06-01
?
慕码人2483693

TA贡献1860条经验 获得超9个赞

在支持库的v21中,现在有了一个解决方案:它被称为RoundedBitmapDrawable.

它基本上就像一个普通的绘图,除了你给它一个拐角半径的剪裁用:

setCornerRadius(float cornerRadius)

所以,从Bitmap src和目标ImageView,它看起来会是这样的:

RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(res, src);dr.setCornerRadius(cornerRadius);imageView.setImageDrawable(dr);


查看完整回答
反对 回复 2019-06-01
  • 4 回答
  • 0 关注
  • 573 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信