I am using glide to load an image to a CircleImageView. But the images is not showing. I am using a List Adapter class.
class ListAdapter (private val myDataset: MutableList<Aplaca>):
RecyclerView.Adapter<ListAdapter.MyViewHolder>() {
class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
val name = itemView.name
val pic = itemView.pic
......
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val current = myDataset.get(position)
holder.name.setText(current.getMyName())
val imgTxt = current.getImg()
Glide.with(holder.pic.context).load(imgTxt).into(holder.pic)
}
I also tried with .apply(RequestOptions.circleCropTransform())
Here is my CircleImageView code:
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp" />
And yes, I have Internet-permission.
首先,尝试设置不带滑行的图像,如果可行,请尝试将图像设置为不带滑行和带滑行的普通图像视图,否则如果这两种方法有效,我不知道
Try Using
Try Code
override fun onBindViewHolder(holder: YelpViewHolder, position: Int) {
val current = myDataset.get(position)
holder.name.setText(current.getMyName())
val imgTxt = current.getImg()
Glide.with(context).load(imgTxt).apply(RequestOptions()
.transform(CenterCrop(),RoundedCorners(180))).into(holder.pic)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.