我有这个问题的答案,但是我在寻找它时花了太多时间。
这就是我创建这个问题的原因,这样对其他人来说会更容易。
您不能像通常的 View 那样使用形状 @drawable 将图像的角弄圆。
这就是为什么您需要在代码中对 Image 进行一些更改。
最佳答案
这是使用 Material Design 的另一种方法ShapeableImageView
为形状和 cornerFamily
创建一个主题
<style name="ImageView.Corner" parent="">
<item name="cornerSizeTopRight">8dp</item>
<item name="cornerSizeTopLeft">8dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
<item name="cornerFamily">rounded</item>
</style>
现在在 XML 中添加 ShapeableImageView:<com.google.android.material.imageview.ShapeableImageView
android:layout_width="75dp"
android:layout_height="75dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/temp_product_image"
app:shapeAppearanceOverlay="@style/ImageView.Corner"/>
我想要完整的 ShapeableImageView:<style name="ImageView.Round" parent="">
<item name="cornerSize">50%</item>
</style>
全圆输出:就是这样快乐编码:)。
关于android - ImageView 只有底角或顶角是圆角的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66138001/