圆形图片视图显示方形图片

4
我想在 RecyclerView 中添加一个 CircleImageView 和 TextView 的列表,但它显示为正方形图像,像这样,但我想显示圆形图像。enter image description here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:padding="16dp"
    android:background="@drawable/category_bg"
    android:layout_margin="4dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/image_view"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@color/purple_200" />
        <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_weight="1"
        android:text="Title"
        android:textColor="@color/black"
        android:textStyle="bold"
        android:textSize="18sp"
        android:gravity="center_vertical"
        android:padding="8dp"
        />

</LinearLayout>

另外,我已经添加了圆形图片视图的依赖。

implementation 'de.hdodenhof:circleimageview:3.1.0'

帮我找出这段代码中的错误


3
你确定部署到设备后它显示的是正方形吗?在设计视图中可能会显示为正方形。 - AgentP
非常感谢您的评论,它在设备部署后显示。 - Monu Rohilla
2个回答

2
请重新构建您的项目,并确保在build.gradle中成功将其实现添加到项目中:

enter image description here


1
谢谢你回答我的问题,但是在强制刷新之后,应用程序部署出现了另一个问题,显示了循环图像。 - Monu Rohilla

0

重新构建您的项目,并确保在重新构建之前,您的build.gradle已成功添加到项目中。然后清除项目缓存,这样它就可以正常工作了。


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