【问题标题】:Unexecpted white frame around Cardview on KitKat but not on Lollipop在 KitKat 上的 Cardview 周围出现意外的白框,但在 Lollipop 上却没有
【发布时间】:2015-07-11 13:03:09
【问题描述】:

我在 kitkat 上的 cardview 周围有一个 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"

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

【问题讨论】:

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


    【解决方案1】:

    我也有这个问题。尝试调用:

    setPreventCornerOverlap(false);
    

    在 CardView 上。这对我有用。

    另外 - 你可能不需要cardUseCompatPadding = "true"

    【讨论】:

    • 谢谢玛吉。它解决了这个问题。我使用了相关的 XML 属性 cardPreventCornerOverlap。
    • 我使用了 XML 属性 cardPreventCornerOverlap 但我收到此错误错误:任务':app:processDebugResources'的执行失败。 > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Developer\AppData\Local\Android\Sdk\build-tools\21.1.1\ aapt.exe'' 以非零退出值 1 结束
    猜你喜欢
    • 2013-12-29
    • 2018-01-08
    • 2015-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多