【发布时间】:2021-10-24 21:45:41
【问题描述】:
我在具有圆角的父 CardView 中嵌入了卡片视图(我将此父 CardView 命名为 CV1)。当我滚动CV1的内容时,子cardview与CV1重叠并取消了CV1的圆角(如视频中的箭头所示),另一方面TextView,ImageView被很好地裁剪,我们总是看到圆角的地图。请参阅:线程年份: 注意:这只发生在 Android API 28 上一切正常。
即使我添加 app:cardPreventCornerOverlap="true" 和
app:cardUseCompatPadding="true"
代码如下
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
fibe:cardCornerRadius="15dp"
android:layout_margin="32dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
<include layout="@layout/item_list" />
</LinearLayout>
</ScrollView>
</androidx.cardview.widget.CardView>
这里有视频。
Rendering on Tablet with Android API 24 : We have error here
Rendering on Tablet with Android API 28 : Everything is good here
更新 1:item_list 布局代码
<?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:layout_width="216dp"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:orientation="vertical">
<androidx.cardview.widget.CardView
style="@style/RoundedCornersContentItem"
android:layout_width="match_parent"
android:layout_height="148dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/content_item_badge_background"/>
<TextView
style="@style/FlowPanelHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="Very long title for my card" />
</LinearLayout>
【问题讨论】:
-
this 是不是同样的问题?
-
@Cheticamp 它是相似的。就我而言,我没有使用 MaterialCardView
-
MaterialCardview 扩展了 CardView,所以我认为这可能是同一个问题。 this bug report 似乎也能识别它。您可以发布 item_list 布局的 XML 吗?
-
@Cheticamp 查看代码更新中的
item_list布局..
标签: android android-layout android-cardview