Reputation: 154
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
Upvotes: 1
Views: 584
Reputation: 81
about the elevation,use app:cardElevation
instead
and about background,use app:cardBackgroundColor
Upvotes: 1
Reputation: 2688
This link has usefull information about difference of card view and material card view . and answer to second question : Using material components require material components 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="Theme.MaterialComponents.Light.NoActionBar">
<!-- 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>
Upvotes: 1
Reputation: 364868
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."
Upvotes: 1