可形变ImageView圆角处理后出现黑边

4
在对可定形的图像视图进行边缘圆角处理后,我仍然在圆角周围看到黑色边缘。 Image with black edges 这是我的XML代码:
<com.google.android.material.imageview.ShapeableImageView
    android:id="@+id/shapeableImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/background"
    android:scaleType="fitXY"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:shapeAppearance="@style/article_shape" />

请问您能否添加您的@style/article_shape代码? - Android Geek
其中一个父元素具有黑色背景。 - Praveen
1
这是我的样式代码:<style name="article_shape"> <item name="cornerSizeTopLeft">20dp</item> <item name="cornerFamilyTopLeft">rounded</item> <item name="cornerSizeBottomRight">10dp</item> <item name="cornerFamilyBottomRight">rounded</item> - codewithbawo
2个回答

2

app:shapeAppearanceOverlay="@style/article_shape" 真的起到了作用。当你在模拟器或设备上运行时,黑色边缘将不会反射。谢谢


但是当我通过代码截取屏幕时,位图的背景仍然显示为黑色。 - Parth Anjaria

0

检查 Application 部分中的 hardwareAccelerated 设置,在 Androidanifest.xml 文件中:

android:hardwareaccelerated="true"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接