Android 4.4从CardView中移除阴影
我试图从Cardview中移除阴影。Android 4.4从CardView中移除阴影,android,android-layout,layout,android-support-library,Android,Android Layout,Layout,Android Support Library,我试图从Cardview中移除阴影。 我在android v4.4.2上使用了android support v7 Cardview 我的布局外观: <android.support.v7.widget.CardView android:id="@+id/cardContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:backgro
我在android v4.4.2上使用了android support v7 Cardview 我的布局外观:
<android.support.v7.widget.CardView
android:id="@+id/cardContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
card_view:cardBackgroundColor="@color/transparent"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/include_profile_header" />
<include layout="@layout/include_profile_footer" />
</RelativeLayout>
</android.support.v7.widget.CardView>
迄今为止:
android:background="@null"
但你仍然可以在我附上的图片中看到上面的阴影
在4.4中,无法从cardview中删除阴影。任何低于5.0的标高都不起作用,因此4.4中的所有cardview都是带有阴影的图像 要创建带有阴影的卡,请使用卡视图:cardElevation 属性CardView在Android上使用真实立面和动态阴影 5.0(API级别21)及更高版本,并退回到早期版本上的编程阴影实现。有关详细信息,请参阅 保持兼容性
我刚刚通过使用相对布局解决了这个问题。只需将CardView值更改为相对布局,您将获得基本相同的结果,但如果没有阴影,只需将下面的代码添加到CardView标记中即可 别忘了加上 更新 也可以尝试在cardview中输入以下代码
app:cardElevation="0dp"
app:cardMaxElevation="0dp"
app:cardCornerRadius="1dp"
app:cardUseCompatPadding="true"
app:cardPreventCornerOverlap="false"
android:background="@null"
app:cardCornerRadius
应大于0(>0),否则将引发异常
我正在使用API 28支持库
实现'com.android.support:cardview-v7:28.0.0'
尝试删除cardBackgroundColor@motis10android:cardBackgroundColor不存在和card\u view:cardBackgroundColor不存在card\u view:cardBackgroundColor=“@color/transparent”删除此项,但会将其添加到我的布局白色背景中。正如您在图片中看到的,我希望它是透明的。这意味着我需要将布局CardView更改为另一个视图组,并在需要时手动添加阴影?但是,它的声音很弱。你说5.0之前的cardview没有使用cardElevation、maxcardElevation、cardPreventCornerOverlap、@motis10我不明白你在说什么5.0之前没有elevation,那怎么用呢?如果你想要一个不同的外观,在棒棒糖之前,你需要创建你自己想要的图像
app:cardElevation="0dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardElevation="0dp"
app:cardMaxElevation="0dp"
app:cardCornerRadius="1dp"
app:cardUseCompatPadding="true"
app:cardPreventCornerOverlap="false"
android:background="@null"