我正在尝试在MaterialCardView
控件周围添加边框,但由于某种原因,这无法工作。我已经添加了相关的依赖项,但它似乎仍然没有任何效果。
已添加依赖项
dependencies {
...
implementation 'com.google.android.material:material:1.0.0'
...
}
XML
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp"
app:strokeColor="@android:color/black"
app:strokeWidth="2dp">
[...]
</com.google.android.material.card.MaterialCardView>
当前结果
移除透明卡背景颜色,因为它正在覆盖应用程序背景。
app:cardBackgroundColor="@android:color/transparent"