【问题标题】:CardView styling not showing on deviceCardView 样式未显示在设备上
【发布时间】:2018-07-05 23:33:39
【问题描述】:

我正在尝试为我的活动的卡片视图制作自定义样式。它就像我在 Android Studio 中想要的那样工作。但是当我在我的设备上运行它时 - Galaxy S7 Edge android 7.0 - cardview 属性没有改变。它使用布局样式中的背景,其余属性 - 高程、角半径和卡片背景似乎被忽略了。 我在日志中没有收到任何错误。

布局使用style="@style/AddItemStyle"

卡使用style="@style/AddItemStyle.CardView"

这就是卡片样式

<style name="AddItemStyle.CardView" parent="CardView">
    <item name="cardBackgroundColor">@color/card_bg</item>
    <item name="cardCornerRadius">15dp</item>
    <item name="cardElevation">15dp</item>
</style>

就是布局风格

<style name="AddItemStyle" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/mySecondary</item>
    <item name="colorAccent">@color/ColorMain</item>
    <item name="editTextColor">@color/ColorMain</item>
    <item name="android:background">@color/mySecondary</item>
</style>

In android studio

On my phone

【问题讨论】:

    标签: runtime cardview


    【解决方案1】:

    出于某种原因,从清单中的活动中删除 android:theme="@style/AddItemStyle" 解决了问题。我不知道为什么,但它奏效了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-14
      • 2023-01-18
      • 2020-04-30
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多