如何在android中制作完整的圆形图像视图

Aam*_*hah 16 android imageview android-layout android-canvas

可能重复:
如何使图像适合android中的圆形框架

我想要一个360度圆形的Image View,我在stackoverflow上找到了相关的解决方案,但它们都在图像视图中产生了圆角.但我想要完整的圆形图像视图.

对于圆角图像视图链接是:

有什么想法吗.

Waz*_*_Be 33

获取位图:

Bitmap bitmap = getthebitmapyouwanttoshowinacirclefromsomewhere;
Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Run Code Online (Sandbox Code Playgroud)

使用着色器:

BitmapShader shader = new BitmapShader (bitmap,  TileMode.CLAMP, TileMode.CLAMP);
Paint paint = new Paint();
        paint.setShader(shader);
Run Code Online (Sandbox Code Playgroud)

画画布;

Canvas c = new Canvas(circleBitmap);
c.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, bitmap.getWidth()/2, paint);
Run Code Online (Sandbox Code Playgroud)

设置图像:

myImageView.setImageBitmap(circleBitmap);
Run Code Online (Sandbox Code Playgroud)