MaterialCardView向后兼容

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

所有MaterialCardView在Lollipop之前变黑了,特别是API 16,如下所示:

enter image description here

我尝试为卡片制作样式,但它不起作用,但是当我使用CardView时它可以工作。

<android.support.design.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="120dp"
                android:foreground="@color/transparent"
                android:id="@+id/matcard"
                android:background="@color/white"
                app:cardPreventCornerOverlap="false"
                app:cardUseCompatPadding="true"
                app:cardCornerRadius="12dp"
                app:strokeColor="@color/colorPrimary"
                app:strokeWidth="0.5dp"
                android:layout_margin="5dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal"
                    > ...
 </android.support.design.card.MaterialCardView>

有没有办法解决这个问题,而无需重写我的代码?

Solved

问题解决了 !通过迁移到AndroidX

android android-cardview android-library materialcardview
1个回答
0
投票

通过迁移到AndroidX解决并添加新材料库以进行gradle:

implementation 'com.google.android.material:material:1.0.0'
© www.soinside.com 2019 - 2024. All rights reserved.