本文介绍了如何在android的全圆形图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
How使图像配合到圆形框架Android中
我希望有一个360度的圆形图像查看,我发现计算器相关解决方案,但他们在图像视图中的所有收益圆角。但我想全圆形图像视图。
I want a 360 degree circular shape Image View, I found related solutions on stackoverflow, but they were all yielding rounded corners in image view. But i want full circular image view.
有关圆角的图像视图链接:
For rounded corners image view links are:
- 中的ImageView圆角
- How作出的ImageView有圆角
- Rounded corners in imageView
- How to make an ImageView to have rounded corners
任何想法。
推荐答案
获取位图:
Bitmap bitmap = getthebitmapyouwanttoshowinacirclefromsomewhere;
Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
使用着色器:
BitmapShader shader = new BitmapShader (bitmap, TileMode.CLAMP, TileMode.CLAMP);
Paint paint = new Paint();
paint.setShader(shader);
画在画布上;
Draw the canvas;
Canvas c = new Canvas(circleBitmap);
c.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, bitmap.getWidth()/2, paint);
设置图像:
myImageView.setImageBitmap(circleBitmap);
这篇关于如何在android的全圆形图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!