CardView即使cardElevation设置为0dp仍显示阴影边框。

问题描述 投票:0回答:1

我对这个小部件(CardView)真的没有多大希望。他们确实犯了某种错误,并且要修复它,我们需要付出一些实际的努力。如果cardBackgroundColor不透明,则一切看起来都很好(尽管没有阴影,也没有边框和阴影)可能仍然有点可见,但对您的眼睛不是很敏感)。

现在如果将cardBackgroundColor设置为透明(@android:color/transparent),则可以在CardView周围看到带有阴影的迹线。

[我知道以这种样式(无边框和阴影的透明背景)使用CardView有点奇怪,但是样式可能会因某些设置而改变,因此应首先使用。

这里是代码(主要是CardView引起的不良影响:]

<!-- ra is namespace at http://schemas.android.com/apk/res-auto -->
<android.support.v7.widget.CardView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      ra:cardElevation="0dp"          
      ra:cardBackgroundColor="@android:color/transparent"
  >

以下是屏幕截图,显示此CardView有什么问题:

enter image description here

第一张图片就是我想要的。第二个是背景不透明(白色)时看起来不错。最后一个是失败的图片,显示了我提到的某种错误。

[我想知道是否可能必须切换到使用其他布局(并且是否有任何支持阴影的要求,我不得不切换到使用CardView,这花费了我的时间来更改代码,并不十分方便)。]]

我对这个小部件(CardView)真的没有多大希望。他们肯定是他们做的某种错误,并且要修复它,我们需要付出一些实际的努力。如果cardBackgroundColor不透明,则...

android android-layout xamarin xamarin.android android-cardview
1个回答
1
投票

我有完全相同的问题,尽管背景透明时CardView布局中有card_view:cardElevation="0dp",但显示的是高程。这是CardView与RecyclerView一起使用的时候。

© www.soinside.com 2019 - 2024. All rights reserved.