可能重复:
如何使图像适合android中的圆形框架
我想要一个360度圆形的Image View,我在stackoverflow上找到了相关的解决方案,但它们都在图像视图中产生了圆角.但我想要完整的圆形图像视图.
对于圆角图像视图链接是:
有什么想法吗.
我有1个圆形imageview,我想在bitview中放置位图.但是当我设置压缩的位图图像时,它总是矩形的.请帮我在圆形imageview中设置位图.
谢谢
我一直在研究如何在Android中创建圆形ImageView.在阅读StackOverflow上有关该主题的问题之后:
和
我已经将我自己的ImageView放在一起,使用链接作为指导来完成我需要它做的事:带边框的圆形图像.
以下是我使用的代码:
public class CircularImageView extends ImageView
{
private int borderWidth = 5;
private int viewWidth;
private int viewHeight;
private Bitmap image;
private Paint paint;
private Paint paintBorder;
private BitmapShader shader;
public CircularImageView(Context context) {
super(context);
setup();
}
public CircularImageView(Context context, AttributeSet attrs) {
super(context, attrs);
setup();
}
public CircularImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setup();
}
private void setup()
{
// init paint
paint = new Paint();
paint.setAntiAlias(true);
paintBorder = new …Run Code Online (Sandbox Code Playgroud)