Android 简单显示圆角图片

1.添加一个ImgaView。




    

    

2.编写修改bitmap的函数

    private RoundedBitmapDrawable rectRoundBitmap(Bitmap bitmap){
        //创建RoundedBitmapDrawable对象
        RoundedBitmapDrawable roundImg = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
        //抗锯齿
        roundImg.setAntiAlias(true);
        //设置圆角半径
        roundImg.setCornerRadius(15);
        return roundImg;
    }

3.显示修改完后的bitmap

        ImageView im=(ImageView)findViewById(R.id.imageView);
        Bitmap image= BitmapFactory.decodeResource(getResources(), R.drawable.test);
        im.setImageDrawable( rectRoundBitmap(image));

4.效果图

Android 简单显示圆角图片_第1张图片

你可能感兴趣的:(Android 简单显示圆角图片)