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

查看:915
本文介绍了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天全站免登陆