Cardview - 卡片周围的白色边框 [英] Cardview - white border around card

查看:74
本文介绍了Cardview - 卡片周围的白色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 cardview 作为我正在编写的自定义视图的根.我使用 v7 支持库.我的 XML 看起来像这样:

I am using a cardview as the root of a custom view I am writing. I using the v7 support library. My XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginRight="6dp"
        card_view:cardElevation="0dp">

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

        <!-- some other views -->
    </LinearLayout>
</android.support.v7.widget.CardView>

我的问题是我的卡片视图周围出现了白色边框.看起来它在那里表示海拔,因为它在右侧更厚.我已经尝试在我的 XML 中调整 cardElevationMaxCardElevation ,如下所示:card_view:cardElevation="0dp"

My problem is that I am getting a white border around my card view. It looks like it is there to indicate elevation as it is thicker on the right side. I've tried adjusting cardElevation and MaxCardElevation in my XML like so : card_view:cardElevation="0dp"

在我的自定义视图中扩展 CardView 并使用此布局的代码中:

and in code in my custom view that extends CardView and uses this layout:

setCardElevation(0);
setMaxCardElevation(0);

但是白色边框仍然存在.我不知道如何摆脱它.如果有人对发生这种情况的原因有任何意见或有关如何删除白色边框的建议,我们将不胜感激.非常感谢.

But the white border persists. I'm not sure how to get rid of it. If anyone had any input into why this is happening or suggestions on how I can remove the white border it would be appreciated. Thanks much.

推荐答案

我知道现在有点晚了,但对于任何有类似问题的人:

I know it's a bit late, but for anyone having a similar problem:

我遇到了同样的问题:在棒棒糖之前的设备上显示了白色边框.

I had the same issue: A white border was shown on pre-lollipop devices.

我解决了它设置cardPreventCornerOverlap 到您的 XML 上的 false.

I solved it setting the cardPreventCornerOverlap to false on your XML.

像这样:

<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginRight="6dp"
    card_view:cardPreventCornerOverlap="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- some other views -->
    </LinearLayout>
</android.support.v7.widget.CardView>

希望这有帮助!

这篇关于Cardview - 卡片周围的白色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆