[英]How to draw border to an imageview with Coil in Android?
I am using 'Coil' to have circular imageview.我正在使用“线圈”来制作圆形 imageview。 I want to draw a circular border to this circular imageview.
我想为这个圆形 imageview 画一个圆形边框。 How to do it with using Coil?
如何使用线圈来做到这一点?
This is where I load the image:这是我加载图像的地方:
binding.imageviewFaceDetectionSelfieCircle.load(R.drawable.ic_avatar) {
transformations(CircleCropTransformation())
}
This is where the image^s XML:这是图像^s XML的位置:
<ImageView
android:id="@+id/imageview_face_detection_selfie_circle"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/imageview_face_detection_id_card"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="70dp"/>
There is no such option in Coil
. Coil
中没有这样的选项。 To draw border you can use ShapableImageView
from "com.google.android.material:material:1.2.0"
要绘制边框,您可以使用
"com.google.android.material:material:1.2.0"
中的ShapableImageView
<com.google.android.material.imageview.ShapeableImageView
android:layout_width="50dp"
android:layout_height="50dp"
app:strokeColor="@color/blue"
app:strokeWidth="3dp" />
If you check the Coil's Pull Requests, you can see here that the user t-kurimura tried to implement the functionality that you want.如果您检查 Coil 的 Pull Requests,您可以在此处看到用户t-kurimura尝试实现您想要的功能。 See his commit and make your own CircleCropTransformation class.
查看他的提交并制作您自己的CircleCropTransformation class。 It's very simple and it works!
这很简单,而且很有效! I made it in my project!
我在我的项目中做到了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.