Android圆形图像黑色

Android圆形图像黑色,android,image,rounding,scale,stretch,Android,Image,Rounding,Scale,Stretch,我抬头看了看四周的图像。这是可行的,但图像不是完全圆的 我该怎么做才能使图像获得完整的图像视图。 android:scaleType=“fitXY”不起作用 这是使图像变圆的代码: public Bitmap getRoundedShape(Bitmap scaleBitmapImage) { // TODO Auto-generated method stub int targetWidth = 150; int targetHeight = 150; Bit

我抬头看了看四周的图像。这是可行的,但图像不是完全圆的

我该怎么做才能使图像获得完整的图像视图。 android:scaleType=“fitXY”不起作用

这是使图像变圆的代码:

public Bitmap getRoundedShape(Bitmap scaleBitmapImage) {
    // TODO Auto-generated method stub
    int targetWidth = 150;
    int targetHeight = 150;
    Bitmap targetBitmap = Bitmap.createBitmap(targetWidth,
            targetHeight,Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(targetBitmap);
    Path path = new Path();
    path.addCircle(((float) targetWidth - 1) / 2,
            ((float) targetHeight - 1) / 2,
            (Math.min(((float) targetWidth),
                    ((float) targetHeight)) / 2),
            Path.Direction.CCW);

    canvas.clipPath(path);
    Bitmap sourceBitmap = scaleBitmapImage;
    canvas.drawBitmap(sourceBitmap,
            new Rect(0, 0, sourceBitmap.getWidth(),
                    sourceBitmap.getHeight()),
            new Rect(0, 0, targetWidth,
                    targetHeight), null);
    return targetBitmap;
}
当加法除以2时

我的XML:

<ImageView
    android:layout_width="120dp"
    app:srcCompat="@drawable/round_image"
    android:id="@+id/imageView"
    android:background="@drawable/round_image"
    android:layout_height="120dp"
    android:layout_below="@+id/lblEmail"
    android:layout_centerHorizontal="true" />

<ImageView
    android:layout_width="120dp"
    app:srcCompat="@mipmap/profiel_dark"
    android:id="@+id/ivProfilePic"
    android:layout_height="120dp"
    android:layout_below="@+id/lblEmail"
    android:layout_alignLeft="@+id/imageView"
    android:layout_alignStart="@+id/imageView"
    android:padding="5dp" />


我更新了我的答案,您可以看看@ArmanP的可能副本。这给了我同样的问题。为什么不将圆角效果应用到图像本身并删除另一个imagview呢。