我正在使用android.support.v7.widget.CardView
图书馆并遇到一些问题。
在这里,我仅CardViews
使用一些余量堆叠了3个。在Android L上运行时,看不到/绘制了前2张卡的顶部阴影。
这是API级别16的绘图卡。
是否有可能总是画出顶部阴影?
谢谢。
编辑:xml代码
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
根据我的研究,我相信GPU绘图和高度的更新会导致这种情况。由于卡片位于相同的海拔高度且背景相同,因此平台会将它们混合在一起。这就是为什么较旧的版本由于不支持高程而绘制了一些边框的原因。
我的解决方法是为底部卡添加0dp高程,然后为中间卡添加1dp,顶部卡将其默认高程保持为2dp。现在有轻微的边框可见。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句