我不知道我应该在哪里解决这个问题,如果是我的错,Picasso Lib 或 Cardview 库中存在问题。
基本上我有一个 CardView
包含一个图像(全卡覆盖)和一个 TextView
覆盖。
在 Android 5.0 设备上运行代码时,一切正常,并且图像得到了 圆角。
但是,如果我在 5.0 之前的设备上运行它,图像会与 Cardlayout
重叠并且没有圆角。
您可以在此图片上查看比较:
这里有一些代码 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/