Material 3 Android - 深色主题使用阴影而不是浅色高程。有没有人经历过这个?如何解决问题?
Material 3 Android - dark theme uses shadows instead of lighter color elevations. Has anyone experienced this? How to solve a problem?
MaterialComponents 工作正常并使用 elevationOverlayColor。
enter image description here
但是Material3...
enter image description here
夜间主题:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HiNote" parent="Theme.Material3.Dark">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryVariant">@color/primaryDarkColor</item>
<item name="colorOnPrimary">@color/primaryTextColor</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/secondaryColor</item>
<item name="colorSecondaryVariant">@color/secondaryDarkColor</item>
<item name="colorOnSecondary">@color/secondaryTextColor</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="colorOnSurface">@color/white</item>
<item name="elevationOverlayColor">@color/primaryColor</item>
<item name="backgroundColor">@color/backGroundDark</item>
<item name="android:textColorHint">@color/hintTextColor</item>
</style>
<style name="Theme.HiNote.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.HiNote.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.HiNote.PopupOverlay" parent="ThemeOverlay.Material3.Dark" />
卡片:
<com.google.android.material.card.MaterialCardView
android:id="@+id/note_card"
style="?attr/materialCardViewElevatedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/backgroundColor"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/note_timestamp">
而且应用栏受到影响,所以我很长时间都无法解决这个问题。也许有某种类型的高度可以设置?
也许我做错了什么?
逐条实施codelab后,我达到了预期的效果。
MaterialComponents 工作正常并使用 elevationOverlayColor。 enter image description here 但是Material3... enter image description here 夜间主题:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HiNote" parent="Theme.Material3.Dark">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryVariant">@color/primaryDarkColor</item>
<item name="colorOnPrimary">@color/primaryTextColor</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/secondaryColor</item>
<item name="colorSecondaryVariant">@color/secondaryDarkColor</item>
<item name="colorOnSecondary">@color/secondaryTextColor</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="colorOnSurface">@color/white</item>
<item name="elevationOverlayColor">@color/primaryColor</item>
<item name="backgroundColor">@color/backGroundDark</item>
<item name="android:textColorHint">@color/hintTextColor</item>
</style>
<style name="Theme.HiNote.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.HiNote.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.HiNote.PopupOverlay" parent="ThemeOverlay.Material3.Dark" />
卡片:
<com.google.android.material.card.MaterialCardView
android:id="@+id/note_card"
style="?attr/materialCardViewElevatedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/backgroundColor"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/note_timestamp">
而且应用栏受到影响,所以我很长时间都无法解决这个问题。也许有某种类型的高度可以设置? 也许我做错了什么?
逐条实施codelab后,我达到了预期的效果。