更改日光主题的卡片和背景颜色

时间:2020-10-06 05:04:26

标签: android material-ui

这是我的cardview的一部分。我也使用深色/浅色主题。问题是卡的背景是由@style/Theme.AppCompat.Daynight控制的,而不是由ColorPrimary控制的。

如何更改卡的颜色?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:theme="@style/Theme.MaterialComponents.DayNight">

  <com.google.android.material.card.MaterialCardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="10dp"
    android:theme="@style/Theme.AppCompat.DayNight"
    card_view:cardCornerRadius="4dp"
    card_view:cardElevation="4dp">

0 个答案:

没有答案