实质卡片视图和仅卡片视图的区别是什么?为什么不应用某些属性?

for example I added elevation attr to MaterialCardView, but it doesn't work. and also customizing with background.xml doesn't work. why it happens. and what is better to use? between them

评论
Ida
Ida

This link has usefull information about difference of card view and material card view . and answer to second question : Using material components require material theme. Make sure to use material theme in your project to be able to customize view.

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">@color/accent</item>
  </style>
</resources>
点赞
评论
uqui
uqui

The biggest difference is the use of a MaterialShapeDrawable as background implementing some Material features, such as shaping and elevation overlays for Dark Themes.
Also MaterialCardView supports checking and dragging.

About the elevation use the app:cardElevation attribute.
About the background check your log.You should have an info message: "Setting a custom background is not supported."

点赞
评论