android - Appcompat CardView 和 Picasso 没有圆角

标签 android android-appcompat picasso cardlayout

我不知道我应该在哪里解决这个问题,如果是我的错,Picasso Lib 或 Cardview 库中存在问题。

基本上我有一个 CardView 包含一个图像(全卡覆盖)和一个 TextView 覆盖。

Android 5.0 设备上运行代码时,一切正常,并且图像得到了 圆角

但是,如果我在 5.0 之前的设备上运行它,图像会与 Cardlayout 重叠并且没有圆角。

您可以在此图片上查看比较: comparison

这里有一些代码 fragment :

layout_row.xml

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/pandaImage"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop" />

    <TextView
        android:id="@+id/pandaName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/pandaImage"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@color/photo_tint"
        android:clickable="true"
        android:focusable="true"
        android:gravity="center"
        android:textColor="@android:color/white"
        android:textSize="24sp" />

</RelativeLayout>

以及加载图像的回收器适配器:

@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
    Photo p = photos.get(i);
    Picasso.with(mContext).load(p.getUrl()).fit().into(viewHolder.mImage);
    viewHolder.mPandaName.setText(p.getTitle());
}

最佳答案

根据文档,这是设计的:

Due to expensive nature of rounded corner clipping, on platforms before L, CardView does not clip its children that intersect with rounded corners. Instead, it adds padding to avoid such intersection (See setPreventCornerOverlap(boolean) to change this behavior).

the CardView docs了解更多信息。

关于android - Appcompat CardView 和 Picasso 没有圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26552372/

相关文章:

android - 在 ConstraintLayout 中向 <include> 添加约束

java - Android wifimanager启用网络似乎启用了错误的网络

android - java.lang.IllegalStateException : You need to use a Theme. AppCompat 主题(或后代)与此 Activity 。钛

android - 应该使用android :showAsAction when not using the appcompat library

android - 将 Square Picasso 的缓存大小限制为最大 60MB

android - 如何使用 picasso 调整 ImageView 占位符的大小

android - 如何将进度条添加到 Picasso 库

android - 如何获取特殊的gadget ID?

安卓.view.InflateException : on writing a custom imageView

java - appcompat_v7 和每个 eclipse 项目中的错误