2016-07-24 76 views
0

我的Android版本是4.2,我试图从删除白色边框和空间,但我作为card_view:cardPreventCornerOverlap="false"解决方案从xmlns:app="http://schemas.android.com/apk/res-auto"命名空间不起作用正确的Android从cardview在API级别删除白色边框4

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:elevation="0dp" 
    card_view:cardPreventCornerOverlap="false"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/market_item_background"> 

     <ImageView 
      android:id="@+id/market_thumbnail" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:scaleType="centerCrop"/> 

    </RelativeLayout> 

这是我的应用程序,我用CardView

enter image description here

+0

您是否尝试过下列属性? card_view:cardPreventCornerOverlap =“假” card_view:cardUseCompatPadding =“真” – Amir

+0

@Amir这个选项,因为'cardUseCompatPadding'它,因为我得到微胖的cardview –

+0

cardUseCompatPadding是**,如果我们将此属性设置为true,那么保证金作品所有版本都一样**使用-2余量,并猜测你的问题将被修复。 – Amir

回答

2

尝试设置的一部分

setCardElevation(0); 
setMaxCardElevation(0); 

card_view:cardPreventCornerOverlap="false" 

来源:Cardview - white border around card

+0

是的,这个解决方案只在我动态地尝试改变时才起作用,谢谢 –

0

更换android:layout_margin="10dp" android:layout_padding="10dp"

0

我认为设置setMaxCardElevation(0)将足以在这种情况下。 无需setCardElevation(0)card_view:cardPreventCornerOverlap="false"