Android-ImageView仅圆了一个角 [英] Android - ImageView with rounded only one corner
问题描述
我要这样创建ImageView(图像的右侧):
I want to create ImageView like this (right side of the image):
我在CardView布局中使用它,因此我在卡片上有圆角,但是我需要单独创建图像的左下角(或使用右上角).
I have it in CardView layout so I have rounded corners of the card but I need to create rounded left bottom corner of the image alone (or with top right).
我尝试了几种选择,但均无法正常工作.
I tried several options but nothing work correctly.
我该怎么做?你有小费吗?
How can I do this? Do you have some tip?
推荐答案
您可以使用材料组件库.
带有版本 1.2.0-alpha03
的是新的 ShapeableImageView
.
You can use the Material Components Library.
With the version 1.2.0-alpha03
there is the new ShapeableImageView
.
仅在您的布局中使用:
<com.google.android.material.imageview.ShapeableImageView
app:srcCompat="@drawable/..."
../>
然后在您的代码中将 ShapeAppearanceModel
应用于:
And in your code apply the ShapeAppearanceModel
with:
float radius = getResources().getDimension(R.dimen.default_corner_radius);
imageView.setShapeAppearanceModel(imageView.getShapeAppearanceModel()
.toBuilder()
.setTopRightCorner(CornerFamily.ROUNDED,radius)
.setBottomLeftCorner(CornerFamily.ROUNDED,radius)
.build());
这篇关于Android-ImageView仅圆了一个角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!