android - 在 KitKat 上 Cardview 周围出现意外的白框,但在 Lollipop 上却没有

标签 android android-5.0-lollipop android-4.4-kitkat android-cardview appearance

我在 kitkat 上的卡片 View 周围有一个无法解释的 1 或 2 dp 厚的白框。这个白框没有出现在 Lollipop 上,这是我所期望的。

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cardview="http://schemas.android.com/apk/res-auto"
    android:id="@+id/podcasts_cardView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:background="?attr/colorPrimary"
    cardview:cardUseCompatPadding="true"
    cardview:cardCornerRadius="3dp"
    cardview:cardElevation="5dp">

请注意 colorPrimary 主题属性是深蓝色,我正在使用:

cardview:cardUseCompatPadding="true"

它负责处理平台上的填充问题。

最佳答案

我也遇到过这个问题。尝试调用:

setPreventCornerOverlap(false);

在 CardView 上。这对我有用。

此外 - 您可能不需要 cardUseCompatPadding = "true"

关于android - 在 KitKat 上 Cardview 周围出现意外的白框,但在 Lollipop 上却没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31357466/

相关文章:

android - 如何在 wordpress [通过 android] 中对用户进行身份验证

android - Android Lollipop 中属于不同 Activity 的 fragment 之间的共享元素转换

android - Google 应用内计费,升级到 Android L Dev Preview 后出现 IllegalArgumentException : Service Intent must be explicit,

带有工具栏的 Android 5.0 Material 选项卡

Android 4.4 - 播放默认音乐播放器

android - 将 SSL 套接字打开到套接字 io 服务器时出现 NullPointerException

安卓:CountDownTimer 不工作

java - 进程挂起 waitFor() 方法

android - Cordova 平台添加 android 在列出 Android 目标时不起作用

android - setColorFilter 似乎不适用于 kitkat